Completed
Push — master ( dd8c88...3beeb1 )
by Beñat
01:33
created

DoctrineORMCustomTypesPass::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Shared Kernel library.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[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 LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler;
13
14
use LIN3S\SharedKernel\Infrastructure\Persistence\Doctrine\ORM\Phone\Types\PhoneType;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * @author Beñat Espiña <[email protected]>
20
 */
21
class DoctrineORMCustomTypesPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container)
24
    {
25
        $customTypes = $container->getParameter('doctrine.dbal.connection_factory.types');
26
        $customTypes = array_merge($customTypes, [
27
            'phone' => [
28
                'class'     => PhoneType::class,
29
                'commented' => true,
30
            ],
31
        ]);
32
33
        $container->setParameter('doctrine.dbal.connection_factory.types', $customTypes);
34
        $container->findDefinition('doctrine.dbal.connection_factory')->replaceArgument(
35
            0, '%doctrine.dbal.connection_factory.types%'
36
        );
37
    }
38
}
39