From 070c1f963ad74ffe7c1746b933e81eae3d9b076a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Sep 2023 15:22:31 +0200 Subject: [PATCH] Upgrade recipes: symfony/framework --- config/packages/framework.yaml | 9 +++++- config/packages/test/framework.yaml | 6 ---- config/preload.php | 4 --- config/routes/dev/framework.yaml | 3 -- config/routes/framework.yaml | 4 +++ config/services.yaml | 8 +----- public/index.php | 26 +++-------------- src/Kernel.php | 43 ----------------------------- symfony.lock | 10 +++---- 9 files changed, 21 insertions(+), 92 deletions(-) delete mode 100644 config/packages/test/framework.yaml delete mode 100644 config/routes/dev/framework.yaml create mode 100644 config/routes/framework.yaml diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 9fe9aff..b996de4 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -14,7 +14,7 @@ framework: - '%env(resolve:TRUSTED_HOSTS)%' #csrf_protection: true - #http_method_override: true + http_method_override: false # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. @@ -22,6 +22,7 @@ framework: handler_id: null cookie_secure: auto cookie_samesite: lax + storage_factory_id: session.storage.factory.native #esi: true #fragments: true @@ -33,3 +34,9 @@ framework: ## sf4 check: ou à déplacer dans un chill.yaml assets: json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + +when@test: + framework: + test: true + session: + storage_factory_id: session.storage.factory.mock_file diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml deleted file mode 100644 index 23906ec..0000000 --- a/config/packages/test/framework.yaml +++ /dev/null @@ -1,6 +0,0 @@ -framework: - test: true - session: - storage_id: session.storage.mock_file - assets: - json_manifest_path: NULL diff --git a/config/preload.php b/config/preload.php index 064bdcd..5ebcdb2 100644 --- a/config/preload.php +++ b/config/preload.php @@ -1,9 +1,5 @@ handle($request); -$response->send(); -$kernel->terminate($request, $response); +return function (array $context) { + return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); +}; diff --git a/src/Kernel.php b/src/Kernel.php index 1cd0572..779cd1f 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -3,52 +3,9 @@ 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\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; class Kernel extends BaseKernel { use MicroKernelTrait; - - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - - public function registerBundles(): iterable - { - $contents = require $this->getProjectDir().'/config/bundles.php'; - foreach ($contents as $class => $envs) { - if ($envs[$this->environment] ?? $envs['all'] ?? false) { - yield new $class(); - } - } - } - - public function getProjectDir(): string - { - 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.'/{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'); - } } diff --git a/symfony.lock b/symfony.lock index 3aeb1c2..6f1bff0 100644 --- a/symfony.lock +++ b/symfony.lock @@ -531,20 +531,18 @@ "version": "v5.1.3" }, "symfony/framework-bundle": { - "version": "4.4", + "version": "5.4", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "4.4", - "ref": "24eb45d1355810154890460e6a05c0ca27318fe7" + "version": "5.4", + "ref": "3cd216a4d007b78d8554d44a5b1c0a446dab24fb" }, "files": [ - "config/bootstrap.php", "config/packages/cache.yaml", "config/packages/framework.yaml", - "config/packages/test/framework.yaml", "config/preload.php", - "config/routes/dev/framework.yaml", + "config/routes/framework.yaml", "config/services.yaml", "public/index.php", "src/Controller/.gitignore",