RuleEngineCompiler::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
4
namespace Oliverde8\PhpEtlBundle\DependencyInjection\Compiler;
5
6
7
use Oliverde8\Component\RuleEngine\RuleApplier;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class RuleEngineCompiler implements CompilerPassInterface
13
{
14
    public const TAG = "etl.rule";
15
16
17
    /**
18
     * You can modify the container here before it is dumped to PHP code.
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        $ruleApplierDefinition = $container->getDefinition(RuleApplier::class);
23
24
        $rules = $container->findTaggedServiceIds(self::TAG);
25
        $rulesReferences = [];
26
27
        foreach ($rules as $id => $parameters) {
28
            $rulesReferences[] = new Reference($id);
29
        }
30
31
        $ruleApplierDefinition->setArgument('$rules', $rulesReferences);
32
    }
33
34
}