minor #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
This commit is contained in:
Nicolas Grekas 2018-02-11 11:56:59 +01:00
commit cecda0b16b
1 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\TypedReference;
use Symfony\Component\HttpFoundation\Request;
/**
* Creates the service-locators required by ServiceValueResolver.
@ -148,6 +149,10 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
continue;
}
if (Request::class === $type) {
continue;
}
if ($type && !$p->isOptional() && !$p->allowsNull() && !class_exists($type) && !interface_exists($type, false)) {
$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);