CommandHandlerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 3
1
<?php
2
3
namespace Tactics\CommandBusBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * Class CommandBusCompilerPass
11
 * @package Tactics\CommandBusBundle\DependencyInjection
12
 */
13
class CommandHandlerPass implements CompilerPassInterface
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    public function process(ContainerBuilder $container)
19
    {
20
        if (! $container->hasDefinition('command_bus')) {
21
            return;
22
        }
23
24
        $definition = $container->getDefinition('command_bus');
25
        $handlerServices = $container->findTaggedServiceIds('command_handler');
26
27
        foreach ($handlerServices as $id => $attributes) {
28
            $definition->addMethodCall(
29
                'registerHandler',
30
                array(new Reference($id))
31
            );
32
        }
33
    }
34
}