src/App/Kernel.php line 26

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\Loader\Configurator\RoutingConfigurator;
  9. class Kernel extends BaseKernel
  10. {
  11.     use MicroKernelTrait;
  12.     private const CONFIG_EXTS '.{php,xml,yaml,yml}';
  13.     /**
  14.      * {@inheritDoc}
  15.      *
  16.      * This is being used to prevent a massive number of deprecation notices from clogging up profiler storage.
  17.      */
  18.     protected function initializeContainer(): void
  19.     {
  20.         parent::initializeContainer();
  21.         try {
  22.             $class $this->getContainerClass();
  23.             $buildDir $this->getBuildDir();
  24.             if (file_exists($buildDir.'/'.$class.'Deprecations.log')) {
  25.                 @unlink($buildDir.'/'.$class.'Deprecations.log');
  26.             }
  27.         } catch (\Exception $e) {
  28.             // NOOP
  29.         }
  30.     }
  31.     public function registerBundles(): iterable
  32.     {
  33.         $contents = require $this->getProjectDir().'/config/bundles.php';
  34.         foreach ($contents as $class => $envs) {
  35.             if ($envs[$this->environment] ?? $envs['all'] ?? false) {
  36.                 yield new $class();
  37.             }
  38.         }
  39.     }
  40.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader): void
  41.     {
  42.         $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
  43.         // Feel free to remove the "container.autowiring.strict_mode" parameter
  44.         // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
  45.         $container->setParameter('container.autowiring.strict_mode'true);
  46.         $container->setParameter('container.dumper.inline_class_loader'true);
  47.         $confDir $this->getProjectDir().'/config';
  48.         $loader->load($confDir.'/{parameters}'.self::CONFIG_EXTS'glob');
  49.         $loader->load($confDir.'/{parameters}/*'.self::CONFIG_EXTS'glob');
  50.         $loader->load($confDir.'/{parameters}/'.$this->environment.'/*'.self::CONFIG_EXTS'glob');
  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.     protected function configureRoutes(RoutingConfigurator $routes): void
  57.     {
  58.         $confDir $this->getProjectDir().'/config';
  59.         $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS'glob');
  60.         $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS'glob');
  61.         $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS'glob');
  62.     }
  63. }