Passed
Push — master ( 8c44f8...c22a19 )
by Gerrit
14:38
created

RDMCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 16
rs 9.9666
1
<?php
2
/**
3
 * Copyright (C) 2019 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\RDMBundle\DependencyInjection;
14
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Alias;
18
19
final class RDMCompilerPass implements CompilerPassInterface
20
{
21
    public function process(ContainerBuilder $container)
22
    {
23
        /** @var array<int, array<string, mixed>> $doctrineConfigs */
24
        $doctrineConfigs = $container->getExtensionConfig('doctrine');
25
        
26
        foreach ($doctrineConfigs as $doctrineConfig) {
27
            foreach ($doctrineConfig['dbal']['connections'] as $name => $connection) {
28
                
29
                $container->setAlias(
30
                    'addiks_rdm.doctrine.orm.configuration', 
31
                    new Alias(sprintf(
32
                        'doctrine.orm.%s_configuration',
33
                        $name
34
                    ))
35
                );
36
                break 2;
37
            }
38
        }
39
    }
40
}
41