|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PHPPM\Tests\Fixtures\Symfony; |
| 4 | + |
| 5 | +use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
| 6 | +use Symfony\Component\Config\Loader\LoaderInterface; |
| 7 | +use Symfony\Component\Config\Resource\FileResource; |
| 8 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 9 | +use Symfony\Component\Routing\RouteCollectionBuilder; |
| 10 | + |
| 11 | +class Kernel extends \Symfony\Component\HttpKernel\Kernel |
| 12 | +{ |
| 13 | + use MicroKernelTrait; |
| 14 | + |
| 15 | + const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
| 16 | + |
| 17 | + public function registerBundles() |
| 18 | + { |
| 19 | + $contents = require $this->getProjectDir() . '/config/bundles.php'; |
| 20 | + foreach ($contents as $class => $envs) { |
| 21 | + if (isset($envs['all']) || isset($envs[$this->environment])) { |
| 22 | + yield new $class(); |
| 23 | + } |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) |
| 28 | + { |
| 29 | + $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); |
| 30 | + // Feel free to remove the "container.autowiring.strict_mode" parameter |
| 31 | + // if you are using symfony/dependency-injection 4.0+ as it's the default behavior |
| 32 | + $container->setParameter('container.autowiring.strict_mode', true); |
| 33 | + $container->setParameter('container.dumper.inline_class_loader', true); |
| 34 | + $confDir = $this->getProjectDir() . '/config'; |
| 35 | + |
| 36 | + $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); |
| 37 | + } |
| 38 | + |
| 39 | + protected function configureRoutes(RouteCollectionBuilder $routes) |
| 40 | + { |
| 41 | + $confDir = $this->getProjectDir() . '/config'; |
| 42 | + |
| 43 | + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); |
| 44 | + } |
| 45 | + |
| 46 | + public function getProjectDir() |
| 47 | + { |
| 48 | + return __DIR__; |
| 49 | + } |
| 50 | +} |
0 commit comments