Completed
Push — development ( 8ef386...754cf1 )
by Thomas
19s
created

AppKernel::registerBundles()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 18
nc 2
nop 0
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
3
use Symfony\Component\Config\Loader\LoaderInterface;
4
use Symfony\Component\DependencyInjection\ContainerInterface;
5
use Symfony\Component\HttpKernel\Kernel;
6
7
class AppKernel extends Kernel
8
{
9
    /**
10
     * For legacy reasons.
11
     *
12
     * @var AppKernel
13
     */
14
    private static $instance;
15
16
    /**
17
     * Boots the current kernel.
18
     *
19
     * @return void
20
     */
21
    public function boot()
22
    {
23
        parent::boot();
24
        self::$instance = $this;
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function registerBundles()
31
    {
32
        $bundles = [
33
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
34
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
35
            new Symfony\Bundle\TwigBundle\TwigBundle(),
36
            new Symfony\Bundle\MonologBundle\MonologBundle(),
37
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
38
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
39
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
40
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
41
            new JMS\TranslationBundle\JMSTranslationBundle(),
42
            new BestIt\KitchensinkBundle\BestItKitchensinkBundle()
43
        ];
44
45
        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
46
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
47
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
48
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
49
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
50
        }
51
52
        return $bundles;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getRootDir()
59
    {
60
        return __DIR__;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getCacheDir()
67
    {
68
        return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getLogDir()
75
    {
76
        return dirname(__DIR__) . '/var/logs';
77
    }
78
79
    /**
80
     * @param \Symfony\Component\Config\Loader\LoaderInterface $loader
81
     * @return void
82
     * @throws \Exception
83
     */
84
    public function registerContainerConfiguration(LoaderInterface $loader)
85
    {
86
        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
87
    }
88
89
    /**
90
     * Get instance of AppKernel.
91
     *
92
     * @return AppKernel
93
     */
94
    public static function getInstance()
95
    {
96
        return self::$instance;
97
    }
98
99
    /**
100
     * Dependency injection container.
101
     *
102
     * Is not named as getContainer because this is a function of the Kernel.
103
     * It acts as a shortcut for the legacy application to get the container.
104
     *
105
     * @return ContainerInterface
106
     */
107
    public static function Container()
108
    {
109
       return self::getInstance()->getContainer();
110
    }
111
}
112