| 1 | <?php |
||
| 2 | |||
| 3 | declare( strict_types = 1 ); |
||
| 4 | |||
| 5 | namespace WMDE\BannerServer; |
||
| 6 | |||
| 7 | use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
||
| 8 | use Symfony\Component\Config\Loader\LoaderInterface; |
||
| 9 | use Symfony\Component\Config\Resource\FileResource; |
||
| 10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 11 | use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
||
| 12 | use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
||
| 13 | |||
| 14 | class Kernel extends BaseKernel { |
||
| 15 | |||
| 16 | use MicroKernelTrait; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 17 | |||
| 18 | private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; |
||
| 19 | |||
| 20 | public function getCacheDir(): string { |
||
| 21 | return $this->getProjectDir() . '/var/cache/' . $this->environment; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function getLogDir(): string { |
||
| 25 | return $this->getProjectDir() . '/var/log'; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function registerBundles(): \Generator { |
||
| 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 | |||
| 37 | protected function configureContainer( ContainerBuilder $container, LoaderInterface $loader ): void { |
||
| 38 | $container->addResource( new FileResource( $this->getProjectDir() . '/config/bundles.php' ) ); |
||
| 39 | // Feel free to remove the "container.autowiring.strict_mode" parameter |
||
| 40 | // if you are using symfony/dependency-injection 4.0+ as it's the default behavior |
||
| 41 | $container->setParameter( 'container.autowiring.strict_mode', true ); |
||
| 42 | $container->setParameter( '.container.dumper.inline_class_loader', true ); |
||
| 43 | $confDir = $this->getProjectDir() . '/config'; |
||
| 44 | |||
| 45 | $loader->load( $confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob' ); |
||
| 46 | $loader->load( $confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob' ); |
||
| 47 | $loader->load( $confDir . '/{services}' . self::CONFIG_EXTS, 'glob' ); |
||
| 48 | $loader->load( $confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob' ); |
||
| 49 | } |
||
| 50 | |||
| 51 | protected function configureRoutes( RoutingConfigurator $routes ): void { |
||
| 52 | $routes->import( '../config/routes.yaml' ); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |