• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller Filters - Input needed

#18
Interesting. I'm glad everyone seemed to agree that separating the filter logic from the controllers is a good thing.

I have a few questions for the code posted above:

1) Would the $routes array mean that if I had 100 routes that I wanted to use a certain before filter but I did not want in the global score mean that I'd have to to set that filter for each individual one?
For example:

PHP Code:
    public $routes = [
        'admin/*' => [
            'before' => ['isLoggedIn'],
            'after' => ['somethingElse']
        ],
        'profiles/*' => [
            'before' => ['isLoggedIn'],
            'after' => ['somethingElse']
        ],
        'users/*' => [
            'before' => ['isLoggedIn'],
            'after' => ['somethingElse']
        ],
        'posts/*/store' => [
            'before' => ['isLoggedIn'],
            'after' => ['somethingElse']
        ],
        'posts/*/destroy' => [
            'before' => ['isLoggedIn'],
            'after' => ['somethingElse']
        ],
    ]; 

2) Would the $routes array follow the inputted url or the routed url?

3) Would it be simpler if we reversed the array and were able to create multiple routes under a group of filters? I would think it's much easier to copy a group of routes into a filter than add a filter to a bunch of routes.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply


Messages In This Thread
Controller Filters - Input needed - by kilishan - 07-07-2016, 08:39 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 06:46 AM
RE: Controller Filters - Input needed - by arma7x - 07-07-2016, 09:14 PM
RE: Controller Filters - Input needed - by albertleao - 07-10-2016, 10:18 PM
RE: Controller Filters - Input needed - by arma7x - 07-10-2016, 11:42 PM
RE: Controller Filters - Input needed - by arma7x - 07-12-2016, 01:55 AM
RE: Controller Filters - Input needed - by arma7x - 07-13-2016, 12:23 AM
RE: Controller Filters - Input needed - by arma7x - 07-14-2016, 12:37 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.