Skip to content

Commit cecda0b

Browse files
minor symfony#26137 [HttpKernel] don't try to wire Request argument with controller.service_arguments (Tobion)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] don't try to wire Request argument with controller.service_arguments | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This does not make sense as Request is not a service and it's already handled by RequestValueResolver. Also it produces alot of logging messages like the following whenever you only use the Request class in an action but no other service. > Cannot autowire service "service_locator.IXu0y5S": it references class "Symfony\Component\HttpFoundation\Request" but no such service exists. It cannot be auto-registered because it is from a different root namespace. > Removing service-argument resolver for controller "App\Controller\MyController:myAction": no corresponding services exist for the referenced types. Commits ------- 09b9eb2 [HttpKernel] don't try to wire Request argument with controller.service_arguments
2 parents ed42760 + 09b9eb2 commit cecda0b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
2323
use Symfony\Component\DependencyInjection\Reference;
2424
use Symfony\Component\DependencyInjection\TypedReference;
25+
use Symfony\Component\HttpFoundation\Request;
2526

2627
/**
2728
* Creates the service-locators required by ServiceValueResolver.
@@ -148,6 +149,10 @@ public function process(ContainerBuilder $container)
148149
continue;
149150
}
150151

152+
if (Request::class === $type) {
153+
continue;
154+
}
155+
151156
if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type, false)) {
152157
$message = sprintf('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s".', $class, $r->name, $p->name, $type);
153158

0 commit comments

Comments
 (0)