src/Kernel.php line 37

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\DependencyInjection\ContainerBuilder;
  6. use Symfony\Component\Dotenv\Dotenv;
  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 __construct(string $environmentbool $debug)
  14.     {
  15.         (new Dotenv())->load(__DIR__ '/../.env');
  16.         $this->environment $environment;
  17.         $this->debug $debug;
  18.     }
  19.     public function getCacheDir()
  20.     {
  21.         return $this->getProjectDir() . '/var/cache/' $this->environment;
  22.     }
  23.     public function getLogDir()
  24.     {
  25.         return $this->getProjectDir() . '/var/log';
  26.     }
  27.     public function registerBundles()
  28.     {
  29.         $contents = require $this->getProjectDir() . '/config/bundles.php';
  30.         foreach ($contents as $class => $envs) {
  31.             if (isset($envs['all']) || isset($envs[$this->environment])) {
  32.                 yield new $class();
  33.             }
  34.         }
  35.     }
  36.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  37.     {
  38.         $container->setParameter('container.autowiring.strict_mode'true);
  39.         $container->setParameter('container.dumper.inline_class_loader'true);
  40.         $confDir $this->getProjectDir() . '/config';
  41.         $loader->load($confDir '/{packages}/*' self::CONFIG_EXTS'glob');
  42.         $loader->load($confDir '/{packages}/' $this->environment '/**/*' self::CONFIG_EXTS'glob');
  43.         $loader->load($confDir '/{services}' self::CONFIG_EXTS'glob');
  44.         $loader->load($confDir '/{services}_' $this->environment self::CONFIG_EXTS'glob');
  45.     }
  46.     protected function configureRoutes(RouteCollectionBuilder $routes)
  47.     {
  48.         $confDir $this->getProjectDir() . '/config';
  49.         $routes->import($confDir '/{routes}/*' self::CONFIG_EXTS'/''glob');
  50.         $routes->import($confDir '/{routes}/' $this->environment '/**/*' self::CONFIG_EXTS'/''glob');
  51.         $routes->import($confDir '/{routes}' self::CONFIG_EXTS'/''glob');
  52.     }
  53. }