Completed
Push — master ( 206d9f...261a93 )
by Pablo
02:52
created

QueryBusCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
namespace Bruli\EventBusBundle\QueryBus;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class QueryBusCompilerPass implements CompilerPassInterface
9
{
10
    /**
11
     * You can modify the container here before it is dumped to PHP code.
12
     *
13
     * @param ContainerBuilder $container
14
     */
15
    public function process(ContainerBuilder $container)
16
    {
17
        if (!$container->has('bruli.query.bus')) {
18
            return;
19
        }
20
21
        $definition = $container->findDefinition('bruli.bus.options.resolver');
22
        $queryHandlers = $container->findTaggedServiceIds('bruli.query_handler');
23
24
        foreach ($queryHandlers as $id => $tags) {
25
            foreach ($tags as $attributes) {
26
                $definition->addMethodCall('addOption', [$attributes['handles'], $id]);
27
            }
28
        }
29
    }
30
}
31