1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the BenGorFile package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace BenGorFile\FileBundle; |
14
|
|
|
|
15
|
|
|
use BenGorFile\FileBundle\DependencyInjection\Compiler\ApplicationCommandsPass; |
16
|
|
|
use BenGorFile\FileBundle\DependencyInjection\Compiler\ApplicationDataTransformersPass; |
17
|
|
|
use BenGorFile\FileBundle\DependencyInjection\Compiler\ApplicationQueriesPass; |
18
|
|
|
use BenGorFile\FileBundle\DependencyInjection\Compiler\DomainServicesPass; |
19
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* BenGor File bundle's kernel class. |
25
|
|
|
* |
26
|
|
|
* @author Beñat Espiña <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class BenGorFileBundle extends Bundle |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function build(ContainerBuilder $container) |
34
|
|
|
{ |
35
|
|
|
$container->addCompilerPass(new DomainServicesPass(), PassConfig::TYPE_OPTIMIZE); |
36
|
|
|
$container->addCompilerPass(new ApplicationCommandsPass(), PassConfig::TYPE_OPTIMIZE); |
37
|
|
|
$container->addCompilerPass(new ApplicationDataTransformersPass(), PassConfig::TYPE_OPTIMIZE); |
38
|
|
|
$container->addCompilerPass(new ApplicationQueriesPass(), PassConfig::TYPE_OPTIMIZE); |
39
|
|
|
|
40
|
|
|
$this->buildLoadableBundles($container); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Executes the load method of LoadableBundle instances. |
45
|
|
|
* |
46
|
|
|
* @param ContainerBuilder $container The container builder |
47
|
|
|
*/ |
48
|
|
|
protected function buildLoadableBundles(ContainerBuilder $container) |
49
|
|
|
{ |
50
|
|
|
$bundles = $container->getParameter('kernel.bundles'); |
51
|
|
|
foreach ($bundles as $bundle) { |
52
|
|
|
$reflectionClass = new \ReflectionClass($bundle); |
53
|
|
|
if ($reflectionClass->implementsInterface(LoadableBundle::class)) { |
54
|
|
|
(new $bundle())->load($container); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|