LoggerFactoryPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 17
rs 9.9666
c 1
b 0
f 0
cc 3
nc 3
nop 1
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