1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CMS Kernel package. |
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\CMSKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Menu\Types\MenuIdType; |
15
|
|
|
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Menu\Types\MenuItemIdType; |
16
|
|
|
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Menu\Types\MenuTranslationIdType; |
17
|
|
|
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Page\Types\PageIdType; |
18
|
|
|
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Page\Types\PageTranslationIdType; |
19
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @author Beñat Espiña <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class DoctrineORMCustomTypesPass implements CompilerPassInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
public function process(ContainerBuilder $container) |
31
|
|
|
{ |
32
|
|
|
$customTypes = $container->getParameter('doctrine.dbal.connection_factory.types'); |
33
|
|
|
$customTypes = array_merge($customTypes, [ |
34
|
|
|
'menu_id' => [ |
35
|
|
|
'class' => MenuIdType::class, |
36
|
|
|
'commented' => true, |
37
|
|
|
], |
38
|
|
|
'menu_item_id' => [ |
39
|
|
|
'class' => MenuItemIdType::class, |
40
|
|
|
'commented' => true, |
41
|
|
|
], |
42
|
|
|
'menu_translation_id' => [ |
43
|
|
|
'class' => MenuTranslationIdType::class, |
44
|
|
|
'commented' => true, |
45
|
|
|
], |
46
|
|
|
'page_id' => [ |
47
|
|
|
'class' => PageIdType::class, |
48
|
|
|
'commented' => true, |
49
|
|
|
], |
50
|
|
|
'page_translation_id' => [ |
51
|
|
|
'class' => PageTranslationIdType::class, |
52
|
|
|
'commented' => true, |
53
|
|
|
], |
54
|
|
|
]); |
55
|
|
|
|
56
|
|
|
$container->setParameter('doctrine.dbal.connection_factory.types', $customTypes); |
57
|
|
|
$container->findDefinition('doctrine.dbal.connection_factory')->replaceArgument( |
58
|
|
|
0, '%doctrine.dbal.connection_factory.types%' |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|