Completed
Pull Request — master (#90)
by Arnaud
10:16 queued 05:08
created

ActionCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 12
cts 12
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 3
nop 1
crap 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 1
            );
32 1
        }
33 1
    }
34
}
35