Completed
Push — feature/EVO-7964_fundInfo-exte... ( eda009...805323 )
by Bastian
62:49
created

ApiDefinitionLoaderPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 24 4
1
<?php
2
/**
3
 * ApiDefinitionLoaderPass
4
 */
5
6
namespace Graviton\ProxyExtensionBundle\DependencyInjection\Compiler;
7
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
/**
13
 * Class ApiDefinitionLoaderPass
14
 *
15
 * @package Graviton\ProxyExtensionBundle\Definition\Loader
16
 *
17
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
18
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
19
 * @link     http://swisscom.ch
20
 */
21
class ApiDefinitionLoaderPass implements CompilerPassInterface
22
{
23
    /**
24
     * @param ContainerBuilder $container Symfony Service container
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        // always first check if the primary service is defined
29
        if (!$container->has('graviton.proxy.service.loaderfactory')) {
30
            return;
31
        }
32
33
        $definition = $container->findDefinition('graviton.proxy.service.loaderfactory');
34
35
        // find all service IDs with the app.mail_transport tag
36
        $taggedServices = $container->findTaggedServiceIds('graviton.proxy.definition.loader');
37
38
        foreach ($taggedServices as $id => $tags) {
39
            foreach ($tags as $attributes) {
40
                $definition->addMethodCall(
41
                    'addLoaderDefinition',
42
                    array(
43
                        new Reference($id),
44
                        $attributes["alias"]
45
                    )
46
                );
47
            }
48
        }
49
    }
50
}
51