TaggedServicesCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 22
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 4
1
<?php
2
3
namespace Kaliop\eZObjectWrapperBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class TaggedServicesCompilerPass implements CompilerPassInterface
10
{
11
    protected $entityManagerService = 'ezobject_wrapper.entity_manager';
12
13
    public function process(ContainerBuilder $container)
14
    {
15
        if (!$container->hasDefinition($this->entityManagerService)) {
16
            return;
17
        }
18
        $definition = $container->getDefinition($this->entityManagerService);
19
        $taggedServices = $container->findTaggedServiceIds('ezobject_wrapper.repository');
20
        foreach ($taggedServices as $id => $tags) {
21
            foreach ($tags as $attributes) {
22
                /// @todo validate the keys in $attributes, for courtesy to users
23
                $definition->addMethodCall(
24
                    'registerService',
25
                    array(new Reference($id), @$attributes["content_type"])
26
                );
27
            }
28
        }
29
    }
30
}
31