src/Kernel.php line 54

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 getCacheDir()
  14.     {
  15.         return $this->getProjectDir().'/var/cache/'.$this->environment;
  16.     }
  17.     public function getLogDir()
  18.     {
  19.         return $this->getProjectDir().'/var/log';
  20.     }
  21.     public function registerBundles()
  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.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  31.     {
  32.         $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
  33.         $container->setParameter('container.dumper.inline_class_loader'true);
  34.         $confDir $this->getProjectDir().'/config';
  35.         $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS'glob');
  36.         $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'glob');
  37.         $loader->load($confDir.'/{services}'.self::CONFIG_EXTS'glob');
  38.         $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS'glob');
  39.     }
  40.     protected function configureRoutes(RouteCollectionBuilder $routes)
  41.     {
  42.         $confDir $this->getProjectDir().'/config';
  43.         $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS'/''glob');
  44.         $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'/''glob');
  45.         $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS'/''glob');
  46.     }
  47. }