-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Change route context attribute names #2889
Change route context attribute names #2889
Conversation
PropositionPass an optional So we need RouteContextFactoryInterface::createRouteContext():RouteContextInterface;
RouteContext::attach(ServerRequestInterface, RouteContextInterface):ServerRequestInterface; Then, whenever we need that route context, we can grab it from the RouteContext::fromRequest(ServerRequestInterface):RouteContextInterface The Warning: A lot of phpunit test cases would need rewrites. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the _ATTRIBUTE_NAME
suffix from the constants, then it's good to go!
Good to go. |
I'm not familar with v4 yet so I wasn't sure if this attribute names where a public this, but apparently they are (#2892), so changing them is definitely a breaking change. I'd rather see these names as configurable thing (with default names unchanged, |
can confirm that this is a breaking change as per my issue - referencing the docs is one thing (my original code came from v4 docs - one of the basic examples i think) but if possible i would like to see Slim avoid breaking changes in minor releases. |
Your issue is unrelated to this. As I mentioned, pattern matching is done via FastRoute, which isn't code that was touched by this PR.
We do too however using the request attributes directly isn't the correct way to access the route/routing results/base path/etc. While it was originally stated that way in the earlier version of the v4 docs, this was a mistake and has since been changed. Using the |
PR for #2883
The attribute names are even configurable - although I am not sure if that should be an option. If not, let me know - I will remove all the unnecessary calls to static methods and instead hard code the attribute names.
If yes, maybe we could find another solution than using static methods and properties in the
RouteContext
class - I am not totally happy with this static solution.