src/Kernel.php line 18

Open in your IDE?
  1. <?php
  2. namespace App;
  3. use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  4. use Symfony\Component\Config\Loader\LoaderInterface;
  5. use Symfony\Component\Config\Resource\FileResource;
  6. use Symfony\Component\DependencyInjection\ContainerBuilder;
  7. use Symfony\Component\HttpKernel\Kernel as BaseKernel;
  8. use Symfony\Component\Routing\RouteCollectionBuilder;
  9. class Kernel extends BaseKernel
  10. {
  11.     use MicroKernelTrait;
  12.     const CONFIG_EXTS '.{php,xml,yaml,yml}';
  13.     public function registerBundles()
  14.     {
  15.         $contents = require $this->getProjectDir() . '/config/bundles.php';
  16.         foreach ($contents as $class => $envs) {
  17.             if ($envs[$this->environment] ?? $envs['all'] ?? false) {
  18.                 yield new $class();
  19.             }
  20.         }
  21.     }
  22.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  23.     {
  24.         $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
  25.         $container->setParameter('container.dumper.inline_class_loader'true);
  26.         $confDir $this->getProjectDir() . '/config';
  27.         $loader->load($confDir '/{packages}/*' self::CONFIG_EXTS'glob');
  28.         $loader->load($confDir '/{packages}/' $this->environment '/**/*' self::CONFIG_EXTS'glob');
  29.         $loader->load($confDir '/{services}' self::CONFIG_EXTS'glob');
  30.         $loader->load($confDir '/{services}_' $this->environment self::CONFIG_EXTS'glob');
  31.     }
  32.     protected function configureRoutes(RouteCollectionBuilder $routes)
  33.     {
  34.         $confDir $this->getProjectDir() . '/config';
  35.         $routes->import($confDir '/{routes}/*' self::CONFIG_EXTS'/''glob');
  36.         $routes->import($confDir '/{routes}/' $this->environment '/**/*' self::CONFIG_EXTS'/''glob');
  37.         $routes->import($confDir '/{routes}' self::CONFIG_EXTS'/''glob');
  38.     }
  39. }