Completed
Push — master ( 22278e...4226ad )
by Beñat
11:30
created

Lin3sCmsKernelBundle::build()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
rs 8.8571
cc 1
eloc 25
nc 1
nop 1
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;
13
14
use Doctrine\DBAL\Types\Type;
15
use LIN3S\CMSKernel\Infrastructure\Persistence\Doctrine\DBAL\Page\Types\PageIdType;
16
use LIN3S\CMSKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler\DoctrineORMCustomTypesPass;
17
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\HttpKernel\Bundle\Bundle;
20
21
/**
22
 * @author Beñat Espiña <[email protected]>
23
 */
24
class Lin3sCmsKernelBundle extends Bundle
25
{
26
    public function build(ContainerBuilder $container)
27
    {
28
        $container->addCompilerPass(new DoctrineORMCustomTypesPass(), PassConfig::TYPE_OPTIMIZE);
29
30
        $container->loadFromExtension('doctrine', [
31
            'orm' => [
32
                'mappings' => [
33
                    'Lin3sCmsKernelMenu'        => [
34
                        'type'      => 'xml',
35
                        'is_bundle' => false,
36
                        'dir'       => $this->basePath() . '/Menu/Mapping/',
37
                        'prefix'    => 'LIN3S\CMSKernel\Domain\Model\Menu',
38
                    ],
39
                    'Lin3sCmsKernelPage'        => [
40
                        'type'      => 'xml',
41
                        'is_bundle' => false,
42
                        'dir'       => $this->basePath() . '/Page/Mapping/',
43
                        'prefix'    => 'LIN3S\CMSKernel\Domain\Model\Page',
44
                    ],
45
                    'Lin3sCmsKernelSeo'         => [
46
                        'type'      => 'xml',
47
                        'is_bundle' => false,
48
                        'dir'       => $this->basePath() . '/Seo/Mapping/',
49
                        'prefix'    => 'LIN3S\CMSKernel\Domain\Model\Seo',
50
                    ],
51
                    'Lin3sCmsKernelTranslation' => [
52
                        'type'      => 'xml',
53
                        'is_bundle' => false,
54
                        'dir'       => $this->basePath() . '/Translation/Mapping/',
55
                        'prefix'    => 'LIN3S\CMSKernel\Domain\Model\Translation',
56
                    ],
57
                ],
58
            ],
59
        ]);
60
    }
61
62
    private function basePath()
63
    {
64
        $directory = dirname((new \ReflectionClass(self::class))->getFileName());
65
66
        return $directory . '/../../Persistence/Doctrine/ORM';
67
    }
68
}
69