AdminCompilerPass::process()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 23
rs 8.7972
cc 4
eloc 12
nc 4
nop 1
1
<?php
2
3
namespace Ob\CmsBundle\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 AdminCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->hasDefinition('ob.cms.admin_container')) {
14
            return;
15
        }
16
17
        $definition = $container->getDefinition(
18
            'ob.cms.admin_container'
19
        );
20
21
        $taggedServices = $container->findTaggedServiceIds(
22
            'ob.cms.admin'
23
        );
24
25
        foreach ($taggedServices as $id => $tagAttributes) {
26
            foreach ($tagAttributes as $attributes) {
27
                $definition->addMethodCall(
28
                    'addClass',
29
                    array(new Reference($id), $attributes["alias"])
30
                );
31
            }
32
        }
33
    }
34
}
35