Completed
Push — master ( 6693ad...18e2ea )
by Beñat
02:55
created

BenGorFileBenGorFileBundle   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 9 1
A buildLoadableBundles() 0 10 3
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 BenGorFileBenGorFileBundle 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