From 16a2e23c517fc8fafebda292231f302e504a5724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 31 May 2020 19:56:50 +0200 Subject: [PATCH] Updated recipe for symfony/framework-bundle. --- public/index.php | 5 +++- src/Kernel.php | 70 ++++++++---------------------------------------- symfony.lock | 7 +++-- 3 files changed, 18 insertions(+), 64 deletions(-) diff --git a/public/index.php b/public/index.php index 8909910e..f51312c4 100644 --- a/public/index.php +++ b/public/index.php @@ -1,10 +1,13 @@ bootEnv(dirname(__DIR__).'/.env'); if ($_SERVER['APP_DEBUG']) { umask(0000); diff --git a/src/Kernel.php b/src/Kernel.php index 08c5b57e..58608c76 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -1,76 +1,28 @@ . - */ - -declare(strict_types=1); namespace App; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class Kernel extends BaseKernel { use MicroKernelTrait; - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - - public function registerBundles(): iterable + protected function configureContainer(ContainerConfigurator $container): void { - $contents = require $this->getProjectDir().'/config/bundles.php'; - foreach ($contents as $class => $envs) { - if ($envs[$this->environment] ?? $envs['all'] ?? false) { - yield new $class(); - } - } + $container->import('../config/{packages}/*.yaml'); + $container->import('../config/{packages}/'.$this->environment.'/*.yaml'); + $container->import('../config/{services}.yaml'); + $container->import('../config/{services}_'.$this->environment.'.yaml'); } - public function getProjectDir(): string + protected function configureRoutes(RoutingConfigurator $routes): void { - return \dirname(__DIR__); - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); - $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); - $container->setParameter('container.dumper.inline_factories', true); - $confDir = $this->getProjectDir().'/config'; - - $loader->load($confDir.'/parameters.yaml'); - - $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void - { - $confDir = $this->getProjectDir().'/config'; - - $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import('../config/{routes}/'.$this->environment.'/*.yaml'); + $routes->import('../config/{routes}/*.yaml'); + $routes->import('../config/{routes}.yaml'); } } diff --git a/symfony.lock b/symfony.lock index 0327d7d7..41dba529 100644 --- a/symfony.lock +++ b/symfony.lock @@ -558,15 +558,14 @@ "version": "v4.2.3" }, "symfony/framework-bundle": { - "version": "4.4", + "version": "5.1", "recipe": { "repo": "github.com/symfony/recipes", "branch": "master", - "version": "4.4", - "ref": "36d3075b2b8e0c4de0e82356a86e4c4a4eb6681b" + "version": "5.1", + "ref": "37b4ec59eda3eb89705f21a0da7231862495ce0a" }, "files": [ - "./config/bootstrap.php", "./config/packages/cache.yaml", "./config/packages/framework.yaml", "./config/packages/test/framework.yaml",