OperationCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 3
1
<?php
2
3
/**
4
 * This file is part of the Mediapart LaPresseLibre Bundle.
5
 *
6
 * CC BY-NC-SA <https://github.com/mediapart/lapresselibre-bundle>
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mediapart\Bundle\LaPresseLibreBundle\DependencyInjection;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * This is the class that load you tagged services to be used by endpoint
20
 */
21
class OperationCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        $definition = $container->getDefinition('mediapart_lapresselibre.endpoint_factory');
29
        $taggedServices = $container->findTaggedServiceIds('lapresselibre');
30
31
        foreach ($taggedServices as $id => $tags) {
32
            foreach ($tags as $attributes) {
33
                $definition->addMethodCall(
34
                    'register',
35
                    array(new Reference($id), $attributes)
36
                );
37
            }
38
        }
39
    }
40
}
41