Completed
Push — master ( 0eab77...b2f729 )
by Paul
05:35
created

BusinessEntityResolverCompilerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.0534
c 0
b 0
f 0
cc 4
eloc 12
nc 4
nop 1
1
<?php
2
3
namespace Victoire\Bundle\BusinessEntityBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * This compiler is used to inject the security for routes /victoire-dcms
11
 * without needs to define it in the application security.yml.
12
 *
13
 * @author Paul Andrieux
14
 **/
15 View Code Duplication
class BusinessEntityResolverCompilerPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    public function process(ContainerBuilder $container)
18
    {
19
        if (!$container->hasDefinition('victoire_business_entity.resolver.business_entity_resolver')) {
20
            return;
21
        }
22
        $chainDefinition = $container->getDefinition(
23
            'victoire_business_entity.resolver.business_entity_resolver'
24
        );
25
        $taggedServices = $container->findTaggedServiceIds(
26
            'victoire_business_entity.resolver'
27
        );
28
29
        foreach ($taggedServices as $id => $tagAttributes) {
30
            foreach ($tagAttributes as $attributes) {
31
                $chainDefinition->addMethodCall(
32
                    'addResolver',
33
                    [new Reference($id), $attributes['type']]
34
                );
35
            }
36
        }
37
    }
38
}
39