anonymous//src/ThrusterActionsBundle.php$0   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 20
ccs 0
cts 0
cp 0
rs 10
1
<?php
2
3
namespace Thruster\Bundle\ActionsBundle;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
11
/**
12
 * Class ThrusterActionsBundle
13
 *
14
 * @package Thruster\Bundle\ActionsBundle
15
 * @author  Aurimas Niekis <[email protected]>
16
 */
17
class ThrusterActionsBundle extends Bundle
18
{
19
    /**
20
     * @inheritDoc
21
     */
22 1
    public function build(ContainerBuilder $container)
23
    {
24 1
        parent::build($container);
25
26 1
        $container->addCompilerPass(
27
            new class implements CompilerPassInterface
28
            {
29
                /**
30
                 * @inheritDoc
31
                 */
32
                public function process(ContainerBuilder $container)
33
                {
34
                    $executorId         = 'thruster_actions.executor';
35
                    $executorDefinition = new Definition('Thruster\Component\Actions\Executor');
36
37
                    $container->setDefinition($executorId, $executorDefinition);
38
39
                    foreach ($container->findTaggedServiceIds('thruster_action_executor') as $id => $tags) {
40
                        $definition = $container->getDefinition($id);
41
                        $name       = call_user_func([$definition->getClass(), 'getSupportedAction']);
42
43
                        $executorDefinition->addMethodCall('addExecutor', [$name, new Reference($id)]);
44
                    }
45
                }
46
            }
47
        );
48 1
    }
49
}
50