src/Kernel.php line 33

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.     
  14.     public function __construct($environment$debug) {
  15.       date_default_timezone_set('America/Los_Angeles');
  16.       parent::__construct($environment$debug);
  17.     }
  18.     public function getCacheDir()
  19.     {
  20.         return $this->getProjectDir().'/var/cache/'.$this->environment;
  21.     }
  22.     public function getLogDir()
  23.     {
  24.         return $this->getProjectDir().'/var/log';
  25.     }
  26.     public function registerBundles()
  27.     {
  28.         $contents = require $this->getProjectDir().'/config/bundles.php';
  29.         foreach ($contents as $class => $envs) {
  30.             if (isset($envs['all']) || isset($envs[$this->environment])) {
  31.                 yield new $class();
  32.             }
  33.         }
  34.     }
  35.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  36.     {
  37.         $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
  38.         // Feel free to remove the "container.autowiring.strict_mode" parameter
  39.         // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
  40.         $container->setParameter('container.autowiring.strict_mode'true);
  41.         $container->setParameter('container.dumper.inline_class_loader'true);
  42.         $confDir $this->getProjectDir().'/config';
  43.         $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS'glob');
  44.         $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'glob');
  45.         $loader->load($confDir.'/{services}'.self::CONFIG_EXTS'glob');
  46.         $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS'glob');
  47.     }
  48.     protected function configureRoutes(RouteCollectionBuilder $routes)
  49.     {
  50.         $confDir $this->getProjectDir().'/config';
  51.         $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS'/''glob');
  52.         $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS'/''glob');
  53.         $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS'/''glob');
  54.     }
  55. }