Welcome Guest, Not a member yet? Register   Sign In
Apply multiple filters to a single route
#1

I am just getting back into PHP programing after a few years and started with CodeIgniter 4. It is the first framework I have used and I love it.  There is one feature that does seem to be missing though.  The ability to apply multiple filters to a single route would be amazing.  I understand that I can create a filter alias that includes multiple filter classes, but this is kind of falls apart if you need to pass different arguments to those individual filters in a single alias.  Also, creating multiple aliases for each filter combination can get tedious.
Reply
#2

+1 to that. Another useful thing would be to be able to pass parameters from the URL to filters.

That way if we have an ID defined in some segment of the URL could pass it to a filter and use it there.

I am currently doing this getting the segment form the URL in the filter itself but thats not very good.
Reply
#3

You can definitely have multiple filters for a route. I use this regularly from Filters.php. I guess the issue is defining them in Routes.php? Something on my “to do” list is to make filters defined in Filters.php accept arguments, which might be a better way to solve this.
Reply
#4

(08-06-2020, 04:41 AM)MGatner Wrote: You can definitely have multiple filters for a route. I use this regularly from Filters.php. I guess the issue is defining them in Routes.php? Something on my “to do” list is to make filters defined in Filters.php accept arguments, which might be a better way to solve this.

Yes, what we mean is being able to define multiple filters (each of them with arguments - and some of those arguments from the route itself) in Routes.php. When you want to have different combinations for different routes its very very inconvenient having to define each combination in filters.php
Reply
#5

See https://codeigniter4.github.io/CodeIgnit...le-filters
Reply




Theme © iAndrew 2016 - Forum software by © MyBB