DriverCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 21 3
1
<?php
2
3
4
namespace Jarobe\TaskRunnerBundle\DependencyInjection\Compiler;
5
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class DriverCompilerPass implements CompilerPassInterface
11
{
12
13
    /**
14
     * You can modify the container here before it is dumped to PHP code.
15
     *
16
     * @param ContainerBuilder $container
17
     */
18
    public function process(ContainerBuilder $container)
19
    {
20
        $tagName = 'jarobe.task_runner.driver';
21
        $factoryServiceName = 'jarobe.task_runner.driver_factory';
22
23
        if (!$container->has($factoryServiceName)) {
24
            return;
25
        }
26
27
        $definition = $container->findDefinition($factoryServiceName);
28
        $taggedServices = $container->findTaggedServiceIds($tagName);
29
30
        $drivers = [];
31
        foreach ($taggedServices as $id => $tags) {
32
            // add the transport service to the ChainTransport service
33
            $drivers[] = new Reference($id);
34
        }
35
36
        $definition->replaceArgument(0, $drivers);
37
38
    }
39
}
40