src/Kernel.php line 12

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.         // Feel free to remove the "container.autowiring.strict_mode" parameter
  34.         // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
  35.         $container->setParameter('container.autowiring.strict_mode'true);
  36.         $container->setParameter('container.dumper.inline_class_loader'true);
  37.         $confDir $this->getProjectDir().'/config';
  38.         $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS'glob');
  39.         $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'glob');
  40.         $loader->load($confDir.'/{services}'.self::CONFIG_EXTS'glob');
  41.         $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS'glob');
  42.     }
  43.     protected function configureRoutes(RouteCollectionBuilder $routes)
  44.     {
  45.         $confDir $this->getProjectDir().'/config';
  46.         $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'/''glob');
  47.         $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS'/''glob');
  48.         $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS'/''glob');
  49.     }
  50. }