BenGorFileBundle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 12 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 BenGorFile\FileBundle\DependencyInjection\Compiler\RoutesPass;
20
use BenGorFile\FileBundle\DependencyInjection\Compiler\SqlServicesPass;
21
use BenGorFile\FileBundle\DependencyInjection\Compiler\TwigPass;
22
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
23
use Symfony\Component\DependencyInjection\ContainerBuilder;
24
use Symfony\Component\HttpKernel\Bundle\Bundle;
25
26
/**
27
 * BenGor File bundle's kernel class.
28
 *
29
 * @author Beñat Espiña <[email protected]>
30
 */
31
class BenGorFileBundle extends Bundle
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function build(ContainerBuilder $container)
37
    {
38
        $container->addCompilerPass(new DomainServicesPass(), PassConfig::TYPE_OPTIMIZE);
39
        $container->addCompilerPass(new SqlServicesPass(), PassConfig::TYPE_OPTIMIZE);
40
        $container->addCompilerPass(new ApplicationCommandsPass(), PassConfig::TYPE_OPTIMIZE);
41
        $container->addCompilerPass(new ApplicationDataTransformersPass(), PassConfig::TYPE_OPTIMIZE);
42
        $container->addCompilerPass(new ApplicationQueriesPass(), PassConfig::TYPE_OPTIMIZE);
43
        $container->addCompilerPass(new RoutesPass(), PassConfig::TYPE_OPTIMIZE);
44
        $container->addCompilerPass(new TwigPass(), PassConfig::TYPE_OPTIMIZE);
45
46
        $this->buildLoadableBundles($container);
47
    }
48
49
    /**
50
     * Executes the load method of LoadableBundle instances.
51
     *
52
     * @param ContainerBuilder $container The container builder
53
     */
54
    protected function buildLoadableBundles(ContainerBuilder $container)
55
    {
56
        $bundles = $container->getParameter('kernel.bundles');
57
        foreach ($bundles as $bundle) {
58
            $reflectionClass = new \ReflectionClass($bundle);
59
            if ($reflectionClass->implementsInterface(LoadableBundle::class)) {
60
                (new $bundle())->load($container);
61
            }
62
        }
63
    }
64
}
65