1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace App; |
6
|
|
|
|
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
8
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
9
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
11
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
12
|
|
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Kernel. Generated by Symfony. |
16
|
|
|
*/ |
17
|
|
|
class Kernel extends BaseKernel |
18
|
|
|
{ |
19
|
|
|
use MicroKernelTrait; |
|
|
|
|
20
|
|
|
|
21
|
|
|
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
22
|
|
|
|
23
|
|
|
public function __construct(string $environment, bool $debug) |
24
|
|
|
{ |
25
|
|
|
date_default_timezone_set('UTC'); |
26
|
|
|
parent::__construct($environment, $debug); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function registerBundles(): iterable |
30
|
|
|
{ |
31
|
|
|
$contents = require $this->getProjectDir().'/config/bundles.php'; |
32
|
|
|
foreach ($contents as $class => $envs) { |
33
|
|
|
if ($envs[$this->environment] ?? $envs['all'] ?? false) { |
34
|
|
|
yield new $class(); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getProjectDir(): string |
40
|
|
|
{ |
41
|
|
|
return \dirname(__DIR__); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void |
45
|
|
|
{ |
46
|
|
|
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); |
47
|
|
|
$container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); |
48
|
|
|
$container->setParameter('container.dumper.inline_factories', true); |
49
|
|
|
$confDir = $this->getProjectDir().'/config'; |
50
|
|
|
|
51
|
|
|
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); |
52
|
|
|
$loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); |
53
|
|
|
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); |
54
|
|
|
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function configureRoutes(RoutingConfigurator $routes): void |
58
|
|
|
{ |
59
|
|
|
$routes->import('../config/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS); |
60
|
|
|
$routes->import('../config/{routes}/*'.self::CONFIG_EXTS); |
61
|
|
|
|
62
|
|
|
if (is_file($this->getProjectDir().'/config/routes.yaml')) { |
63
|
|
|
$routes->import('../config/routes.yaml'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|