1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoS\QueueBundle\DependencyInjection\Compiler; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
8
|
|
|
|
9
|
|
|
class CustomProviderPass implements CompilerPassInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @inheritDoc |
13
|
|
|
*/ |
14
|
|
|
public function process(ContainerBuilder $container) |
15
|
|
|
{ |
16
|
|
|
if (!$container->hasParameter('uecode_qpush.provider.custom')) { |
17
|
|
|
return; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
$configs = $container->getExtensionConfig('uecode_qpush'); |
21
|
|
|
|
22
|
|
|
foreach($configs[0]['queues'] as $queue => $value) { |
23
|
|
|
$definition = clone $container->getDefinition('dos.queue.provider.doctrine_orm'); |
24
|
|
|
$definition->replaceArgument(0, $queue); |
25
|
|
|
$definition->replaceArgument(1, $value['options']); |
26
|
|
|
|
27
|
|
|
if ($container->hasDefinition('event_dispatcher')) { |
28
|
|
|
$definition->addMethodCall('setEventDispatcher', array(new Reference('event_dispatcher'))); |
29
|
|
|
} else { |
30
|
|
|
$definition->addMethodCall('setEventDispatcher', array(new Reference('debug.event_dispatcher'))); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
$container->getDefinition('uecode_qpush.'. $queue)->replaceArgument(2, $definition); |
34
|
|
|
$container->setDefinition(sprintf('uecode_qpush.%s', $queue), $definition) |
35
|
|
|
->addTag('monolog.logger', ['channel' => 'qpush']) |
36
|
|
|
->addTag('kernel.event_listener', array( |
37
|
|
|
'event' => "kernel.terminate", |
38
|
|
|
'method' => "onKernelTerminate", |
39
|
|
|
'priority' => 255 |
40
|
|
|
)) |
41
|
|
|
; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|