![]() |
Applying multiple filters on a single route definition - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Applying multiple filters on a single route definition (/showthread.php?tid=76946) |
Applying multiple filters on a single route definition - korgoth - 07-06-2020 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 RE: Applying multiple filters on a single route definition - mlurie - 07-27-2020 Bump! I would also like to know the answer to this question. RE: Applying multiple filters on a single route definition - mlurie - 07-27-2020 I found the answer in the documentation. Multiple filters can be assigned to a single alias: https://www.codeigniter.com/user_guide/incoming/filters.html?#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. RE: Applying multiple filters on a single route definition - korgoth - 07-27-2020 (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/incoming/filters.html?#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 RE: Applying multiple filters on a single route definition - mlurie - 07-28-2020 (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/incoming/filters.html?#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. RE: Applying multiple filters on a single route definition - arma7x - 01-08-2022 Bump! I would also like to know the answer to this question. Edit: Filter arguments(https://www.codeigniter.com/user_guide/incoming/filters.html?#filter-arguments) - My problem is not all filter receive same $arguments Solution: - https://github.com/arma7x/Parry/blob/master/app/Config/Services.php#L39-L46 - https://github.com/arma7x/Parry/blob/master/app/Libraries/Filters/Filters.php - only support ['filter' => 'checkMinLevel:0|hasReadPerm'] RE: Applying multiple filters on a single route definition - kenjis - 01-08-2022 Since v4.1.5, multiple filters can be set. See https://codeigniter4.github.io/userguide/incoming/routing.html#applying-filters RE: Applying multiple filters on a single route definition - cahyadiayya - 02-25-2022 try using route group https://codeigniter.com/user_guide/incoming/routing.html#grouping-routes |