1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
6
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
9
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
10
|
|
|
|
11
|
|
|
class Kernel extends BaseKernel |
12
|
|
|
{ |
13
|
|
|
use MicroKernelTrait; |
14
|
|
|
|
15
|
|
|
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
16
|
|
|
|
17
|
|
|
public function getCacheDir(): string |
18
|
|
|
{ |
19
|
|
|
return dirname(__DIR__).'/var/cache/'.$this->environment; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function getLogDir(): string |
23
|
|
|
{ |
24
|
|
|
return dirname(__DIR__).'/var/log'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function registerBundles(): iterable |
28
|
|
|
{ |
29
|
|
|
$contents = require dirname(__DIR__).'/config/bundles.php'; |
30
|
|
|
foreach ($contents as $class => $envs) { |
31
|
|
|
if (isset($envs['all']) || isset($envs[$this->environment])) { |
32
|
|
|
yield new $class(); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void |
38
|
|
|
{ |
39
|
|
|
$confDir = dirname(__DIR__).'/config'; |
40
|
|
|
$loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob'); |
41
|
|
|
if (is_dir($confDir.'/packages/'.$this->environment)) { |
42
|
|
|
$loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); |
43
|
|
|
} |
44
|
|
|
$loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); |
45
|
|
|
$loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes): void |
49
|
|
|
{ |
50
|
|
|
$confDir = dirname(__DIR__).'/config'; |
51
|
|
|
if (is_dir($confDir.'/routes/')) { |
52
|
|
|
$routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob'); |
53
|
|
|
} |
54
|
|
|
if (is_dir($confDir.'/routes/'.$this->environment)) { |
55
|
|
|
$routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); |
56
|
|
|
} |
57
|
|
|
$routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|