Completed
Push — master ( a6c8f9...b97be3 )
by Vladimir
03:52 queued 19s
created

DataTransformerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\DependencyInjection\Compiler;
9
10
use allejo\stakx\DataTransformer\DataTransformer;
11
use allejo\stakx\DataTransformer\DataTransformerManager;
12
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Reference;
15
16
class DataTransformerPass implements CompilerPassInterface
17
{
18
    /**
19
     * You can modify the container here before it is dumped to PHP code.
20
     *
21
     * @param ContainerBuilder $container
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25
        if (!$container->has(DataTransformerManager::class))
26
        {
27
            return;
28
        }
29
30
        $definition = $container->findDefinition(DataTransformerManager::class);
31
        $services = $container->findTaggedServiceIds(DataTransformer::CONTAINER_TAG);
32
33
        foreach ($services as $id => $tags)
34
        {
35
            $definition->addMethodCall('addDataTransformer', [new Reference($id)]);
36
        }
37
    }
38
}
39