Completed
Push — 3.x ( 9aa22d...aa303f )
by Grégoire
04:40
created

AdminMakerCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 3
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * This class injects available admin managers to the AdminMaker.
19
 *
20
 * @author Gaurav Singh Faudjdar <[email protected]>
21
 */
22
final class AdminMakerCompilerPass implements CompilerPassInterface
23
{
24
    const MANAGERS = [
25
        'sonata.admin.manager.orm',
26
        'sonata.admin.manager.doctrine_mongodb',
27
        'sonata.admin.manager.doctrine_phpcr',
28
    ];
29
30
    public function process(ContainerBuilder $container)
31
    {
32
        $availableManagers = [];
33
        foreach (self::MANAGERS as $manager) {
34
            if ($container->hasDefinition($manager)) {
35
                $availableManagers[$manager] = $container->getDefinition($manager);
36
            }
37
        }
38
39
        $definition = $container->getDefinition('sonata.admin.maker');
40
        $definition->replaceArgument(1, $availableManagers);
41
    }
42
}
43