-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Autowiring] Controller/Actions are not autowired if called through twig render*( #35909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You issue come from your controller syntax Since SF 4.1 the first notation is deprecated. The change takes place in SF 4.4 if (!$reason) {
// Deprecated since Symfony 4.1. See Symfony\Component\HttpKernel\Controller\ContainerControllerResolver
$controllers[$id.':'.$action] = $argumentRef;
if ('__invoke' === $action) {
$controllers[$id] = $argumentRef;
}
continue;
} SF 5.0 if (!$reason) {
if ('__invoke' === $action) {
$controllers[$id] = $argumentRef;
}
continue;
} And easier reproductible case was just defining a route in yaml index:
path: /
controller: App\Controller\DefaultController:index # <--- with 1 colon I take a look at the deprecation logs, but using the wrong syntax in 4.4 does not trigger any deprecation :/ |
…lueResolver Single colon syntax when referencing a controller as a service is deprecated since Symfony 4.1 but there was no deprecations trigger on runtime. See symfony#35909
…alueResolver Single colon syntax when referencing a controller as a service is deprecated since Symfony 4.1 but there was no deprecations trigger on runtime. See symfony#35909
Nice @noemi-salaun! Indeed! it is not a bug then...That is interesting the syntax with |
Shall we close then? |
I guess so. I mean 4.1 is a long time ago. If it's happening to someone they may find this closed issue for help. |
…alueResolver Single colon syntax when referencing a controller as a service is deprecated since Symfony 4.1 but there was no deprecations trigger on runtime. See symfony#35909
Fixed in #36017 actually. |
@nicolas-grekas you can close my PR #36010 then. I didn't know if it was a bug in v5.0 or a missing deprecation in v4.1+. But apparently it was a bug ;) |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 5.0
(it works on 4.4)
Description
Autowiring is correctly set up and it is working as expected but not when using
render
functions.https://github.com/Plopix/symfony-autowiring-render-twig-bug/blob/master/sf5/src/Controller/DefaultController.php
OK in SF 4.4, not on SF 5.0
How to reproduce
Here is a reproducer.
https://github.com/Plopix/symfony-autowiring-render-twig-bug
just checkout
The text was updated successfully, but these errors were encountered: