-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] ArgumentResolver should run after kernel.controller_arguments #33205
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
Regarding 2: I'm not sure why the ServiceValueResolver is throwing an exception in that case, wouldn't use that on action arguments to be honest. Could it be that the typehint can be autowired to something and that causes the exception? Personally would ditch action injection because stateless and stateful mixed is a pain. I prefer to keep my stateless (services) in the constructor arguments of services. Regarding 3: You can throw exceptions in a resolver. If you ask me, the resolver is the correct place to fetch those objects.
I don't think that would make any sense. |
One other thing is that on the Resolver I do not have also the controller instance.. which is quite important for my logic...
Well yes.. my services are injected through the constructor.. but there are some services that need the request in order to be generated... (It's a quite complex domain).. But I can not reach to ControllerArguments... maybe I should remove the
Yes if you throw exception then you break the chain.. and there might be another ArgumentResolver that actually supports this. |
What do you need the controller instance for? You can get the configured controller from the request
If you don't tag your controller with the tag and make it public yourself, you won't have the
Supports could return false, but perhaps this isn't the right place to do it then? If you need a very complex structure for this, you could also do it in your controller instead. |
Thank you for this issue. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Description
I saw that @stof created this #18440 PR about adding the new event for the controller arguments.
This is a very useful feature that I would like to use..
What i'd like to achieve is before reaching to the ArgumentResolver to use this event to do some api calls and load some objects.
Then my ArgumentResolver could check from a container that I have if those objects are loaded and if they are then they should be resolved otherwise the flow of the framework must throw exception.
Unfortunately this event is running after the ArgumentResolver.
This order of this raises some questions to me.
https://symfony.com/doc/current/reference/events.html#kernel-controller-arguments
How am I supposed to map the URL parameters to my controller parameters... ?? At the moment when a parameter is not nullable AND no Argument resolver can resolve it then (at least at my application) the
ServiceValueResolver
throws an exception.Is the current order (meaning executing the event after the ArgumentResolver) made by design?
I could do the same inside an ArgumentResolver when the
support
function is called but if the API fails then an exception must be thrown.. and in general it feels kinda dirty.Anyway is it possible to change the order inside the HttpKernel?
The text was updated successfully, but these errors were encountered: