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

NodeSearcherCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 3
nc 3
nop 1
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