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