From 7d538db99a2313aa1392d425e55eba364dca210d Mon Sep 17 00:00:00 2001 From: Quentin Devos <4972091+Okhoshi@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:44:39 +0100 Subject: [PATCH] [FrameworkBundle] Add `router.ignore_cache` config option Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com> --- src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../FrameworkBundle/DependencyInjection/Configuration.php | 3 ++- .../DependencyInjection/FrameworkExtension.php | 4 ++++ .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 1 + .../Tests/DependencyInjection/ConfigurationTest.php | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 52624c2cd173f..e3b5c6cca9461 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG * Add `secrets:reveal` command * Add `rate_limiter` option to `http_client.default_options` and `http_client.scoped_clients` * Attach the workflow's configuration to the `workflow` tag + * Add `router.ignore_cache` config option 7.0 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 8d54f74ef3891..8c0fe1debb8f1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -619,8 +619,9 @@ private function addRouterSection(ArrayNodeDefinition $rootNode): void ->scalarNode('type')->end() ->scalarNode('cache_dir') ->defaultValue('%kernel.build_dir%') - ->setDeprecated('symfony/framework-bundle', '7.1', 'Setting the "%path%.%node%" configuration option is deprecated. It will be removed in version 8.0.') + ->setDeprecated('symfony/framework-bundle', '7.1', 'Setting the "%path%.%node%" configuration option is deprecated. It will be removed in version 8.0. Please use the "ignore_cache" option if you want to ignore the cache in the router.') ->end() + ->booleanNode('ignore_cache')->defaultFalse()->end() ->scalarNode('default_uri') ->info('The default URI used to generate URLs in a non-HTTP context') ->defaultNull() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1fd7881f34877..15b6c6ec19c55 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1181,6 +1181,10 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co $container->setParameter('router.resource', $config['resource']); $container->setParameter('router.cache_dir', $config['cache_dir']); + if ($config['ignore_cache']) { + $container->setParameter('router.cache_dir', null); + } + $router = $container->findDefinition('router.default'); $argument = $router->getArgument(2); $argument['strict_requirements'] = $config['strict_requirements']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index ad02ec370e45d..52299c0dffa99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -120,6 +120,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index b32d8681b43b3..22b35ee42972d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -715,6 +715,7 @@ protected static function getBundleDefaultConfig() 'strict_requirements' => true, 'utf8' => true, 'cache_dir' => '%kernel.build_dir%', + 'ignore_cache' => false, ], 'session' => [ 'enabled' => false,