10000 feature #47496 [FrameworkBundle] Make the Router `cache_dir` configur… · symfony/symfony@1b3b14c · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b3b14c

Browse files
committed
feature #47496 [FrameworkBundle] Make the Router cache_dir configurable (mpdude)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [FrameworkBundle] Make the Router `cache_dir` configurable | Q | A | ------------- | --- | Branch? | 6.2 for features | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#17253 This PR adds a new `framework.router.cache_dir` configuration setting. It will default to `kernel.cache_dir` as previously, but makes it possible to easily re-configure the Router's cache directory. My intended use case is to set it to `~` (`null`) for the `test` environment because I need to modify or otherwise dynamically load routes during tests. Another use case I see for it is to have tenant-specific route configurations and caches in multi-tenancy applications. Commits ------- dd65d30 [FrameworkBundle] Make the Router `cache_dir` configurable
2 parents d9462d9 + dd65d30 commit 1b3b14c

File tree

5 files changed

+5
-1
lines changed

5 files changed

+5
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CHANGELOG
1919
* Add `rate_limiter` configuration option to `messenger.transport` to allow rate limited transports using the RateLimiter component
2020
* Remove `@internal` tag from secret vaults to allow them to be used directly outside the framework bundle and custom vaults to be added
2121
* Deprecate `framework.form.legacy_error_messages` config node
22+
* Add a `framework.router.cache_dir` configuration option to configure the default `Router` `cache_dir` option
2223

2324
6.1
2425
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode)
608608
->children()
609609
->scalarNode('resource')->isRequired()->end()
610610
->scalarNode('type')->end()
611+
->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%')->end()
611612
->scalarNode('default_uri')
612613
->info('The default URI used to generate URLs in a non-HTTP context')
613614
->defaultNull()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
11401140
}
11411141

11421142
$container->setParameter('router.resource', $config['resource']);
1143+
$container->setParameter('router.cache_dir', $config['cache_dir']);
11431144
$router = $container->findDefinition('router.default');
11441145
$argument = $router->getArgument(2);
11451146
$argument['strict_requirements'] = $config['strict_requirements'];

src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
service(ContainerInterface::class),
102102
param('router.resource'),
103103
[
104-
'cache_dir' => param('kernel.cache_dir'),
104+
'cache_dir' => param('router.cache_dir'),
105105
'debug' => param('kernel.debug'),
106106
'generator_class' => CompiledUrlGenerator::class,
107107
'generator_dumper_class' => CompiledUrlGeneratorDumper::class,

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ protected static function getBundleDefaultConfig()
532532
'https_port' => 443,
533533
'strict_requirements' => true,
534534
'utf8' => true,
535+
'cache_dir' => '%kernel.cache_dir%',
535536
],
536537
'session' => [
537538
'enabled' => false,

0 commit comments

Comments
 (0)
0