-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppKernel.php
More file actions
59 lines (47 loc) · 1.89 KB
/
Copy pathAppKernel.php
File metadata and controls
59 lines (47 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
parent::__construct($environment, $debug);
date_default_timezone_set('Asia/Shanghai');
}
public function registerBundles()
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new \AppDemo\AppBundle\AppBundle(),
];
if ($this->getEnvironment() == 'dev') {
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new \Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config/config.yml');
$isDevEnv = $this->getEnvironment() == 'dev';
$loader->load(function (ContainerBuilder $containerBuilder) use ($isDevEnv) {
if ($isDevEnv) {
$containerBuilder->loadFromExtension('web_profiler', [
'toolbar' => true
]);
$containerBuilder->loadFromExtension('framework', [
'router' => [
'resource' => '%kernel.root_dir%/config/routing_dev.yml'
]
]);
}
});
}
}