5 use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait
;
6 use Symfony\Component\Config\Loader\LoaderInterface
;
7 use Symfony\Component\Config\
Resource\FileResource
;
8 use Symfony\Component\DependencyInjection\ContainerBuilder
;
9 use Symfony\Component\HttpKernel\Kernel
as BaseKernel
;
10 use Symfony\Component\Routing\RouteCollectionBuilder
;
12 class Kernel
extends BaseKernel
16 private const CONFIG_EXTS
= '.{php,xml,yaml,yml}';
18 public function registerBundles(): iterable
20 $contents = require $this->getProjectDir().'/config/bundles.php';
21 foreach ($contents as $class => $envs) {
22 if ($envs[$this->environment
] ?? $envs['all'] ?? false) {
28 public function getProjectDir(): string
30 return \
dirname(__DIR__
);
33 protected function configureContainer(ContainerBuilder
$container, LoaderInterface
$loader): void
35 $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
36 $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID
< 70400 || $this->debug
);
37 $container->setParameter('container.dumper.inline_factories', true);
38 $confDir = $this->getProjectDir().'/config';
40 $loader->load($confDir.'/{packages}/*'.self
::CONFIG_EXTS
, 'glob');
41 $loader->load($confDir.'/{packages}/'.$this->environment
.'/*'.self
::CONFIG_EXTS
, 'glob');
42 $loader->load($confDir.'/{services}'.self
::CONFIG_EXTS
, 'glob');
43 $loader->load($confDir.'/{services}_'.$this->environment
.self
::CONFIG_EXTS
, 'glob');
46 protected function configureRoutes(RouteCollectionBuilder
$routes): void
48 $confDir = $this->getProjectDir().'/config';
50 $routes->import($confDir.'/{routes}/'.$this->environment
.'/*'.self
::CONFIG_EXTS
, '/', 'glob');
51 $routes->import($confDir.'/{routes}/*'.self
::CONFIG_EXTS
, '/', 'glob');
52 $routes->import($confDir.'/{routes}'.self
::CONFIG_EXTS
, '/', 'glob');