Passed
Push — master ( f24ea2...036951 )
by Ivan
03:16
created

RegisterStandaloneItemsCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\NavigationBundle\DependencyInjection\Compiler;
6
7
use Everlution\NavigationBundle\Bridge\Item\Container\ItemContainer;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
/**
13
 * Class RegisterStandaloneItemsCompilerPass.
14
 * @author Ivan Barlog <[email protected]>
15
 */
16
class RegisterStandaloneItemsCompilerPass implements CompilerPassInterface
17
{
18
    public function process(ContainerBuilder $container)
19
    {
20
        $registry = $container->findDefinition(ItemContainer::class);
21
        $services = $container->findTaggedServiceIds('everlution.navigation_item');
22
23
        foreach ($services as $id => $tags) {
24
            $registry->addMethodCall(
25
                'addItem',
26
                [$tags[0]['alias'], new Reference($id)]
27
            );
28
        }
29
    }
30
}
31