Completed
Push — master ( 763f53...48946f )
by Beñat
05:13
created

Lin3sSharedKernelBundle::build()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

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