Passed
Push — master ( 7f151c...a80937 )
by Mihai
12:01
created

ServiceContainerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle\DependencyInjection\Compiler;
4
5
use OldSound\RabbitMqBundle\Command\BaseRabbitMqCommand;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class ServiceContainerPass implements CompilerPassInterface
11
{
12
    public function process(ContainerBuilder $container): void
13
    {
14
        foreach ($container->findTaggedServiceIds('console.command') as $id => $attributes) {
15
            $command = $container->findDefinition($id);
16
            if (is_a($command->getClass(), BaseRabbitMqCommand::class, true)) {
17
                $command->addMethodCall('setContainer', [new Reference('service_container')]);
18
            }
19
        }
20
    }
21
}
22