[11.x] Introduce RouteParameter attribute #53080
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Accessing route parameter outside the Controller, in the FormRequest for example, can be done in various ways. In order to have correct IDE completion and good static analysis, we can do :
Both ways feel a bit tricky to me and not very elegant IMHO.
That's why I propose the introduction of the
RouteParameter
attribute which can streamline the syntax, leveraging existingContextualAttribute
and the container :The attribute can be used on any type of route parameter : Model, enum, string, ...