Skip to content

Custom ArgumentResolver priority #14132

Closed
@amenophis

Description

@amenophis

Hi,
It seems the explanation about the priority for a new custom argument resolver is not valid .(https://symfony.com/doc/current/controller/argument_value_resolver.html#adding-a-custom-value-resolver).

While adding a priority is optional, it's recommended to add one to make sure the expected value is injected. The RequestAttributeValueResolver has a priority of 100. As this one is responsible for fetching attributes from the Request, it's recommended to trigger your custom value resolver with a lower priority. This makes sure the argument resolvers are not triggered when the attribute is present. For instance, when passing the user along a sub-requests.

If a create a new ArgumentResolver which in charge to resolve an argument from a route placeholder, if I define the priority the 50 (like in the example), the argument is resolved by RequestAttributeValueResolver and not by mine.
If a define the priority to 255 on my ArgumentResolver, it is well used to resolve my argument.

Unlike explain in the documentation, it seems higher priority is executed before lower priority (like for event dispatcher)

Metadata

Metadata

Assignees

No one assigned

    Labels

    hasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions