Skip to content

Commit

Permalink
Merge pull request #8 from php-enqueue/add-ability-to-change-queue-co…
Browse files Browse the repository at this point in the history
…ntext

Add ability to change used context.
  • Loading branch information
makasim authored Jan 4, 2018
2 parents 55c9eaa + 2180513 commit e2b7252
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function getConfigTreeBuilder()
$rootNode = $tb->root('enqueue_elastica');
$rootNode
->children()
->scalarNode('context')->isRequired()->defaultValue('enqueue.transport.context')->cannotBeEmpty()->end()
->arrayNode('doctrine')
->children()
->arrayNode('queue_listeners')
Expand Down
4 changes: 3 additions & 1 deletion DependencyInjection/EnqueueElasticaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

$container->setAlias('enqueue_elastica.context', $config['context']);

if (false == empty($config['doctrine']['queue_listeners'])) {
foreach ($config['doctrine']['queue_listeners'] as $listenerConfig) {
$listenerId = sprintf(
Expand All @@ -31,7 +33,7 @@ public function load(array $configs, ContainerBuilder $container)

$container->register($listenerId, SyncIndexWithObjectChangeListener::class)
->setPublic(true)
->addArgument(new Reference('enqueue.transport.context'))
->addArgument(new Reference('enqueue_elastica.context'))
->addArgument($listenerConfig['model_class'])
->addArgument($listenerConfig)
->addTag('doctrine.event_subscriber', ['connection' => $listenerConfig['connection']])
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ services:
class: 'Enqueue\ElasticaBundle\Persister\Listener\PurgePopulateQueueListener'
public: true
arguments:
- '@enqueue.transport.context'
- '@enqueue_elastica.context'
tags:
- { name: 'kernel.event_subscriber' }

enqueue_elastica.queue_pager_perister:
class: 'Enqueue\ElasticaBundle\Persister\QueuePagerPersister'
public: true
arguments:
- '@enqueue.transport.context'
- '@enqueue_elastica.context'
- '@fos_elastica.persister_registry'
- '@event_dispatcher'
tags:
Expand Down

0 comments on commit e2b7252

Please sign in to comment.