src/Kernel.php line 69

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. /**
  10.  * Class Kernel
  11.  *
  12.  * @package App
  13.  */
  14. class Kernel extends BaseKernel
  15. {
  16.     use MicroKernelTrait;
  17.     const CONFIG_EXTS '.{php,xml,yaml,yml}';
  18.     /**
  19.      * @return \Generator|iterable|\Symfony\Component\HttpKernel\Bundle\BundleInterface[]
  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.     /**
  31.      * @param ContainerBuilder $container
  32.      * @param LoaderInterface $loader
  33.      * @throws \Exception
  34.      */
  35.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  36.     {
  37.         $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
  38.         $container->setParameter('container.dumper.inline_class_loader'true);
  39.         $confDir $this->getProjectDir() . '/config';
  40. //        /**
  41. //         * CONFIGURE ecommerce121
  42. //         *      | UtilBundle
  43. //         *      | v1.3-dev
  44. //         */
  45. //        $loader->load('../ecommerce121/util-bundle/Resources/config/services.yml');
  46.         $loader->load($confDir '/{packages}/*' self::CONFIG_EXTS'glob');
  47.         $loader->load($confDir '/{packages}/' $this->environment.'/**/*' self::CONFIG_EXTS'glob');
  48.         $loader->load($confDir '/{services}' self::CONFIG_EXTS'glob');
  49.         $loader->load($confDir '/{services}_' $this->environment self::CONFIG_EXTS'glob');
  50.     }
  51.     /**
  52.      * @param RouteCollectionBuilder $routes
  53.      * @throws \Symfony\Component\Config\Exception\LoaderLoadException
  54.      */
  55.     protected function configureRoutes(RouteCollectionBuilder $routes)
  56.     {
  57.         $confDir $this->getProjectDir() . '/config';
  58.         $routes->import($confDir '/{routes}/*' self::CONFIG_EXTS'/''glob');
  59.         $routes->import($confDir '/{routes}/' $this->environment '/**/*' self::CONFIG_EXTS'/''glob');
  60.         $routes->import($confDir '/{routes}' self::CONFIG_EXTS'/''glob');
  61.     }
  62. }