Skip to content

Commit ec2dade

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 7ed3a4b commit ec2dade

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,14 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
13051305
$container->removeDefinition('messenger.middleware.router_context');
13061306
}
13071307

1308+
if (!isset($config['default_uri']) && (
1309+
$container->hasParameter('router.request_context.scheme')
1310+
|| $container->hasParameter('router.request_context.host')
1311+
|| $container->hasParameter('router.request_context.base_url')
1312+
)) {
1313+
trigger_deprecation('symfony/framework-bundle', '7.4', 'Deprecated the container params "router.request_context.scheme", "router.request_context.host" and "router.request_context.base_url", use the "framework.router.default_uri" config instead.');
1314+
}
1315+
13081316
$loader->load('routing.php');
13091317

13101318
if ($config['utf8']) {

0 commit comments

Comments
 (0)