Completed
Push — master ( 70e4e5...5530b2 )
by Joachim
15:31
created

ConsignmentServicePass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 12
1
<?php
2
namespace Loevgaard\DandomainConsignmentBundle\DependencyInjection\Compiler;
3
4
use Loevgaard\DandomainConsignmentBundle\ConsignmentService\ConsignmentServiceCollection;
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ConsignmentServicePass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has(ConsignmentServiceCollection::class)) {
14
            return;
15
        }
16
17
        $definition = $container->findDefinition(ConsignmentServiceCollection::class);
18
19
        $taggedServices = $container->findTaggedServiceIds('ldc.consignment_service');
20
21
        foreach ($taggedServices as $id => $tags) {
22
            $definition->addMethodCall('addConsignmentService', [new Reference($id)]);
23
        }
24
    }
25
}