Passed
Pull Request — master (#101)
by Damien
02:42
created

StorageConfigurationCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
3
namespace DH\DoctrineAuditBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class StorageConfigurationCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container): void
12
    {
13
        if (!$container->hasDefinition('dh_doctrine_audit.configuration')) {
14
            return;
15
        }
16
17
        $config = $container->getParameter('dh_doctrine_audit.configuration');
18
        if (null === $config['storage_entity_manager']) {
19
            return;
20
        }
21
22
        $reference = new Reference($config['storage_entity_manager']);
23
24
        $definition = $container->getDefinition('dh_doctrine_audit.configuration');
25
        $definition->replaceArgument(4, $reference);
26
    }
27
}
28