ConverterPass::addHandlersToService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.7333
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Kaliop\EzFindSearchEngineBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
use Symfony\Component\DependencyInjection\Definition;
9
10
abstract class ConverterPass implements CompilerPassInterface
11
{
12
    protected function addHandlersToService(ContainerBuilder $container, $service, $taggedService)
13
    {
14
        /** @var Definition $criterionConverterDefinition */
15
        $criterionConverterDefinition = $container->findDefinition($service);
16
17
        $services = $container->findTaggedServiceIds($taggedService);
18
19
        foreach ($services as $id => $tags) {
20
            $criterionConverterDefinition->addMethodCall(
21
                'addHandler',
22
                [
23
                    new Reference($id),
24
                ]
25
            );
26
        }
27
    }
28
29
}
30