Skip to content

Commit 3493bcc

Browse files
committed
Deprecate container params router.request_context.*
The `framework.router.default_uri` config is used to define the request context as fallback for the case that no HTTP request is available. But it does not affect the container params - `router.request_context.base_url` - `router.request_context.host` - `router.request_context.scheme` They still use the defaults, which are defined in the routing.php config file. This leads to inconsistency and confusion if a third party bundle relies on the container parameters instead of the request context service. This PR deprecates those container params like proposed in #53919.
1 parent e01e689 commit 3493bcc

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

UPGRADE-7.4.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ FrameworkBundle
3333
---------------
3434

3535
* Deprecate `Symfony\Bundle\FrameworkBundle\Console\Application::add()` in favor of `addCommand()`
36+
* Deprecate the container params `router.request_context.scheme`, `router.request_context.host`
37+
and `router.request_context.base_url`, use the `framework.router.default_uri` config instead.
3638

3739
HtmlSanitizer
3840
-------------

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ CHANGELOG
88
* Allow using their name without added suffix when using `#[Target]` for custom services
99
* Deprecate `Symfony\Bundle\FrameworkBundle\Console\Application::add()` in favor of `Symfony\Bundle\FrameworkBundle\Console\Application::addCommand()`
1010
* Add `assertEmailAddressNotContains()` to the `MailerAssertionsTrait`
11+
* Deprecate the container params `router.request_context.scheme`, `router.request_context.host`
12+
and `router.request_context.base_url`, use the `framework.router.default_uri` config instead.
1113

1214
7.3
1315
---

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,9 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
13071307

13081308
$loader->load('routing.php');
13091309

1310+
$container->deprecateParameter('router.request_context.scheme', 'symfony/framework-bundle', '7.4', '"router.request_context.scheme" is deprecated, use the "framework.router.default_uri" config instead.');
1311+
$container->deprecateParameter('router.request_context.host', 'symfony/framework-bundle', '7.4', '"router.request_context.host" is deprecated, use the "framework.router.default_uri" config instead.');
1312+
13101313
if ($config['utf8']) {
13111314
$container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
13121315
}
@@ -1334,8 +1337,7 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
13341337
$container->setParameter('request_listener.https_port', $config['https_port']);
13351338

13361339
if (null !== $config['default_uri']) {
1337-
$container->getDefinition('router.request_context')
1338-
->replaceArgument(0, $config['default_uri']);
1340+
$container->setParameter('router.request_context.base_url', $config['default_uri']);
13391341
}
13401342
}
13411343

0 commit comments

Comments
 (0)