Completed
Pull Request — 5.1 (#2266)
by
unknown
12:07
created

NodeSearcherCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 3
1
<?php
2
3
namespace Kunstmaan\NodeSearchBundle\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 NodeSearcherCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('kunstmaan_node_search.search.service')) {
14
            return;
15
        }
16
17
        $searchers = [];
18
        foreach ($container->findTaggedServiceIds('kunstmaan_node_search.node_searcher') as $id => $tags) {
19
            $searchers[$id] = new Reference($id);
20
        }
21
22
        $container
23
            ->getDefinition('kunstmaan_node_search.search.service')
24
            ->replaceArgument(3, $searchers)
25
        ;
26
    }
27
}
28