-
Notifications
You must be signed in to change notification settings - Fork 38
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
Request attributes are being overridden #86
Comments
Thanks for the report!
In Slim (without this bridge) which one gets the priority? We should probably respect the same priority?
I'm not 100% sure to understand what you meant in the last part? Said another way: what do you think we should do? |
In Slim (and also with Slim-Bridge prior to v3.4) route parameters do not override attributes set in a middleware. Edit: In Slim route parameters gets the priority.
What I meant there was that the change causing this unexpected behaviour was introduced in this PR, and that PR was based in this issue. I think the way @juherr and @reiniermybeats were trying to access route parameters was not correct (and thus the slim-bridge documentation they were relying on), because the Slim documented way to access route parameters is using
I suggest simply reverting the changes introduced in v3.4. |
The path argument management is not specified in the PSR-7 standard. To avoid creating a strong dependency on the Slim framework in my controllers, I am reluctant to utilize its path argument management capabilities there and prefer if slim-bridge (or another middleware) manages it for me. @mnapoli Could you consider implementing this feature? |
I must update my answer. It's a bit fuzzy for me because I didn't find the Slim behaviour documented anywhere, but in any case Slim-Bridge from v3.4 is behaving correctly in line what Slim does. As the PSR-7 standard does no specify how to handle this, it is up to you whether you want to allow this behavior to be configured or not. Thanks anyway for shedding some light ;) |
This PR #84 is causing the request attributes to be overriden.
As stated in the Slim official documentation:
So you can for example have a middleware which sets in the request an attribute called "user" and have also a route with a "user" named argument, causing PHP-DI Slim bridge to override the original attribute value.
The Slim documented way to access route parameters is with $route->getArgument('id') function, so maybe the original issue here was the PHP-DI slim bridge documentation indicating a missuse of getAttribute function.
The text was updated successfully, but these errors were encountered: