-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Multiple route filters #5108
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
Multiple route filters #5108
Conversation
@iRedds Coding standards checking was failed. Run |
*/ | ||
public function getFilterForRoute(string $search, ?string $verb = null): string | ||
public function getFilterForRoute(string $search, ?string $verb = null) |
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.
This is a breaking API change. But it seems we must change the return type for multiple filters.
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.
What are your suggestions?
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.
@MGatner This PR contains public API changes.
Can we include this on the next release or we need to wait for the next major version (v5)?
If we can change the return type, array
(string[]
) is better.
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.
We have to stick to semantic versioning, which means we need to leave the signature or save this for version 5. Workarounds could be adding a new method and deprecating this one, or returning an encoded string (like a CSV of classes & aliases).
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.
If we want to include this in the next version (not v5),
it seems returning an encoded string (like a CSV of classes & aliases) is the only choice.
@iRedds What do you think?
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.
I think this is counterproductive.
The filter alias already contains ":" and "," to separate the alias and parameters. And adding one more separator will complicate read/write (by human).
An array of strings is the best solution in my opinion.
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.
@iRedds I didn't say about RouteCollection::add()
usage.
$collection->add('foo', 'TestController::foo', ['filter' => ['filter1', 'filter2:param']]);
This is not a breaking change. Because the 3rd param type is ?array
.
But if we change public method signatures, it is breaking change.
In this PR, getFilterForRoute()
and enableFilter()
are changed.
So this PR will not be able to be merged until the next major version 5.0.
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.
I think maintainers are too conservative about breaking changes.
If the backward compatibility of commonly used functions is broken, that's BC. It's my opinion.
The current policy negatively affects the improvement and popularization of the framework.
And version 5.0 looks like a meme "ten thousand years later" (c) SBSP
I have nothing to say. ggwp
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.
I also feel strongly constrained by the inability to change the method signatures.
I also understand that the policy of following semantic versioning has its value.
CodeIgniter4/system/Router/Router.php Line 147 in 9843737
Here's my recommendation:
|
@MGatner I sent another PR #5128 with the direction you recommend.
I couldn't think of a way to automatically determine when to use a new method. |
If a user class extends |
@kenjis I understand better after looking at your PR: this is a larger issue than just this one method. I will wait and look these over when I'm on desktop and can compare files more easily. |
Closed in favor of #5128 |
Description
https://forum.codeigniter.com/thread-80117-post-390128.html
Several filters can be specified for a route.
Instead of filter aliases, you can use the name of the filter class.
Also fixed typehint in dockblock in the RouteCollection methods. Missing
Closure
.Checklist: