|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace LIN3S\SharedKernel\Infrastructure\Symfony\Bundle; |
|
15
|
|
|
|
|
16
|
|
|
use LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler\DoctrineORMCustomTypesPass; |
|
17
|
|
|
use LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler\TacticianCommandBusPass; |
|
18
|
|
|
use LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler\TacticianEventsBusPass; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
21
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @author Beñat Espiña <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class Lin3sSharedKernelBundle extends Bundle |
|
27
|
|
|
{ |
|
28
|
|
|
public function build(ContainerBuilder $container) |
|
29
|
|
|
{ |
|
30
|
|
|
$container->addCompilerPass(new TacticianEventsBusPass('domain_event_subscriber')); |
|
31
|
|
|
$container->addCompilerPass(new TacticianCommandBusPass()); |
|
32
|
|
|
|
|
33
|
|
|
if (!$container->hasExtension('doctrine')) { |
|
34
|
|
|
return; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$container->addCompilerPass(new DoctrineORMCustomTypesPass(), PassConfig::TYPE_OPTIMIZE); |
|
38
|
|
|
|
|
39
|
|
|
$container->loadFromExtension('doctrine', [ |
|
40
|
|
|
'orm' => [ |
|
41
|
|
|
'mappings' => [ |
|
42
|
|
|
'Lin3sSharedKernelEmail' => [ |
|
43
|
|
|
'type' => 'xml', |
|
44
|
|
|
'is_bundle' => false, |
|
45
|
|
|
'dir' => $this->basePath() . '/Domain/Model/Email/Mapping/', |
|
46
|
|
|
'prefix' => 'LIN3S\SharedKernel\Domain\Model\Email', |
|
47
|
|
|
], |
|
48
|
|
|
'Lin3sSharedKernelSlug' => [ |
|
49
|
|
|
'type' => 'xml', |
|
50
|
|
|
'is_bundle' => false, |
|
51
|
|
|
'dir' => $this->basePath() . '/Domain/Model/Slug/Mapping/', |
|
52
|
|
|
'prefix' => 'LIN3S\SharedKernel\Domain\Model\Slug', |
|
53
|
|
|
], |
|
54
|
|
|
'Lin3sSharedKernelLocale' => [ |
|
55
|
|
|
'type' => 'xml', |
|
56
|
|
|
'is_bundle' => false, |
|
57
|
|
|
'dir' => $this->basePath() . '/Domain/Model/Locale/Mapping/', |
|
58
|
|
|
'prefix' => 'LIN3S\SharedKernel\Domain\Model\Locale', |
|
59
|
|
|
], |
|
60
|
|
|
'Lin3sSharedKernelZipCode' => [ |
|
61
|
|
|
'type' => 'xml', |
|
62
|
|
|
'is_bundle' => false, |
|
63
|
|
|
'dir' => $this->basePath() . '/Domain/Model/ZipCode/Mapping/', |
|
64
|
|
|
'prefix' => 'LIN3S\SharedKernel\Domain\Model\ZipCode', |
|
65
|
|
|
], |
|
66
|
|
|
], |
|
67
|
|
|
], |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
private function basePath() |
|
72
|
|
|
{ |
|
73
|
|
|
$directory = dirname((new \ReflectionClass(self::class))->getFileName()); |
|
74
|
|
|
|
|
75
|
|
|
return $directory . '/../../Persistence/Doctrine/ORM'; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|