Completed
Pull Request — master (#90)
by Arnaud
05:12 queued 02:13
created

ActionCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
1
<?php
2
3
namespace LAG\AdminBundle\DependencyInjection\CompilerPass;
4
5
use LAG\AdminBundle\LAGAdminBundle;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class ActionCompilerPass implements CompilerPassInterface
11
{
12
    /**
13
     * @param ContainerBuilder $builder
14
     */
15 2
    public function process(ContainerBuilder $builder)
16
    {
17 2
        if (!$builder->hasDefinition(LAGAdminBundle::SERVICE_ID_ACTION_REGISTRY)) {
18 1
            return;
19
        }
20 1
        $actionRegistry = $builder->getDefinition(LAGAdminBundle::SERVICE_ID_ACTION_REGISTRY);
21 1
        $actions = $builder->findTaggedServiceIds(LAGAdminBundle::SERVICE_TAG_ACTION);
22
    
23
        //var_dump($actions);
24
        
25 1
        foreach ($actions as $id => $attributes) {
26
            $actionRegistry
27 1
                ->addMethodCall('add', [
28 1
                    $id,
29 1
                    new Reference($id),
30
                ]
31
            );
32
        }
33 1
    }
34
}
35