LoggerFactoryPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of the XiideaEasyAuditBundle package.
5
 *
6
 * (c) Xiidea <http://www.xiidea.net>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Xiidea\EasyAuditBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Reference;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
18
class LoggerFactoryPass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (false === $container->hasDefinition('xiidea.easy_audit.logger_factory')) {
23
            return;
24
        }
25
26
        $definition = $container->getDefinition('xiidea.easy_audit.logger_factory');
27
28
        $calls = $definition->getMethodCalls();
29
        $definition->setMethodCalls(array());
30
31
        foreach ($container->findTaggedServiceIds('easy_audit.logger') as $id => $attributes) {
32
            $definition->addMethodCall('addLogger', array($id, new Reference($id)));
33
        }
34
35
        $definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
36
    }
37
}
38