|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OldSound\RabbitMqBundle\DependencyInjection\Compiler; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
8
|
|
|
|
|
9
|
|
|
class RegisterPartsPass implements CompilerPassInterface |
|
10
|
|
|
{ |
|
11
|
|
|
public function process(ContainerBuilder $container): void |
|
12
|
|
|
{ |
|
13
|
|
|
$services = $container->findTaggedServiceIds('old_sound_rabbit_mq.base_amqp'); |
|
14
|
|
|
$container->setParameter('old_sound_rabbit_mq.base_amqp', array_keys($services)); |
|
15
|
|
|
if (!$container->hasDefinition('old_sound_rabbit_mq.parts_holder')) { |
|
16
|
|
|
return; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
$definition = $container->getDefinition('old_sound_rabbit_mq.parts_holder'); |
|
20
|
|
|
|
|
21
|
|
|
$tags = [ |
|
22
|
|
|
'old_sound_rabbit_mq.base_amqp', |
|
23
|
|
|
'old_sound_rabbit_mq.binding', |
|
24
|
|
|
'old_sound_rabbit_mq.producer', |
|
25
|
|
|
'old_sound_rabbit_mq.consumer', |
|
26
|
|
|
'old_sound_rabbit_mq.multi_consumer', |
|
27
|
|
|
'old_sound_rabbit_mq.anon_consumer', |
|
28
|
|
|
'old_sound_rabbit_mq.batch_consumer', |
|
29
|
|
|
'old_sound_rabbit_mq.rpc_client', |
|
30
|
|
|
'old_sound_rabbit_mq.rpc_server', |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
foreach ($tags as $tag) { |
|
34
|
|
|
foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { |
|
35
|
|
|
$definition->addMethodCall('addPart', [$tag, new Reference($id)]); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|