Applying multiple filters on a single route definition |
I have tried ti find a solution but failed so far - is it possible to apply multiple filters on a single route?
I have tried the following with no luck PHP Code: $routes->get('/', 'Dashboard::index', ['filter' => 'auth|second_filter']); It seems that the parameter only accepts strings and not arrays and having to define each set of possible filters as an alias is not very convenient
I found the answer in the documentation. Multiple filters can be assigned to a single alias: https://www.codeigniter.com/user_guide/i...l?#aliases. Then that alias can be applied to a route which accomplishes the same thing as applying multiple filters to a single route. I would suggest that this be added to the URI Routing section of the manual in addition to the Filters section where the documentation is currently located.
(07-27-2020, 07:31 PM)mlurie Wrote: I found the answer in the documentation. Multiple filters can be assigned to a single alias: https://www.codeigniter.com/user_guide/i...l?#aliases. Then that alias can be applied to a route which accomplishes the same thing as applying multiple filters to a single route. I would suggest that this be added to the URI Routing section of the manual in addition to the Filters section where the documentation is currently located. While that is true and working - its not the best solution when you want to pass some parameters to the filters. Also if you have more than a couple of filters you should write a different alias for each combination which is not convenient (07-27-2020, 11:35 PM)korgoth Wrote:(07-27-2020, 07:31 PM)mlurie Wrote: I found the answer in the documentation. Multiple filters can be assigned to a single alias: https://www.codeigniter.com/user_guide/i...l?#aliases. Then that alias can be applied to a route which accomplishes the same thing as applying multiple filters to a single route. I would suggest that this be added to the URI Routing section of the manual in addition to the Filters section where the documentation is currently located. I agree this is not the best solution. I would much rather be able to apply multiple filters to a single route. I'm going to put in a feature request here: https://forum.codeigniter.com/forum-29.html. Maybe if you do the same, it will get noticed.
Bump! I would also like to know the answer to this question.
Edit: Filter arguments(https://www.codeigniter.com/user_guide/i...-arguments) - My problem is not all filter receive same $arguments Solution: - https://github.com/arma7x/Parry/blob/mas...hp#L39-L46 - https://github.com/arma7x/Parry/blob/mas...ilters.php - only support ['filter' => 'checkMinLevel:0|hasReadPerm']
Keep calm.
Since v4.1.5, multiple filters can be set.
See https://codeigniter4.github.io/userguide...ng-filters
|
Welcome Guest, Not a member yet? Register Sign In |