|
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
|
|
|
public function boot() |
|
20
|
|
|
{ |
|
21
|
|
|
parent::boot(); |
|
22
|
|
|
self::$instance = $this; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
public function registerBundles() |
|
29
|
|
|
{ |
|
30
|
|
|
$bundles = [ |
|
31
|
|
|
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
32
|
|
|
new Symfony\Bundle\SecurityBundle\SecurityBundle(), |
|
33
|
|
|
new Symfony\Bundle\TwigBundle\TwigBundle(), |
|
34
|
|
|
new Symfony\Bundle\MonologBundle\MonologBundle(), |
|
35
|
|
|
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), |
|
36
|
|
|
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
37
|
|
|
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
|
38
|
|
|
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), |
|
39
|
|
|
new JMS\TranslationBundle\JMSTranslationBundle(), |
|
40
|
|
|
new BestIt\KitchensinkBundle\BestItKitchensinkBundle(), |
|
41
|
|
|
new Knp\Bundle\MenuBundle\KnpMenuBundle(), |
|
42
|
|
|
new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(), |
|
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
|
|
|
* @throws \Exception |
|
82
|
|
|
*/ |
|
83
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
|
84
|
|
|
{ |
|
85
|
|
|
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Get instance of AppKernel. |
|
90
|
|
|
* |
|
91
|
|
|
* @return AppKernel |
|
92
|
|
|
*/ |
|
93
|
|
|
public static function getInstance() |
|
94
|
|
|
{ |
|
95
|
|
|
return self::$instance; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Dependency injection container. |
|
100
|
|
|
* |
|
101
|
|
|
* Is not named as getContainer because this is a function of the Kernel. |
|
102
|
|
|
* It acts as a shortcut for the legacy application to get the container. |
|
103
|
|
|
* |
|
104
|
|
|
* @return ContainerInterface |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function Container() |
|
107
|
|
|
{ |
|
108
|
|
|
return self::getInstance()->getContainer(); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|