LoggerFactoryPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 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
    #[\Override]
21
    public function process(ContainerBuilder $container): void
22
    {
23
        if (false === $container->hasDefinition('xiidea.easy_audit.logger_factory')) {
24
            return;
25
        }
26
27
        $definition = $container->getDefinition('xiidea.easy_audit.logger_factory');
28
29
        $calls = $definition->getMethodCalls();
30
        $definition->setMethodCalls(array());
31
32
        foreach ($container->findTaggedServiceIds('easy_audit.logger') as $id => $attributes) {
33
            $definition->addMethodCall('addLogger', array($id, new Reference($id)));
34
        }
35
36
        $definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
37
    }
38
}
39