Welcome Guest, Not a member yet? Register   Sign In
Controller Filters - Input needed
#19

(07-10-2016, 09:55 PM)kilishan Wrote: So, here's what I'm thinking for the config file. This would seem to cover all of the bases, and still be simple to use, right? I thought of mapping to controllers instead of URI's/routes, but this seemed to make more sense so the application could change the underlying controllers if needed and still be covered.

Code:
<?php namespace Config;

class Filters
{
// Makes reading things below nicer,
// and simpler to change out script that's used.
public $aliases = [
'isLoggedIn' => 'App\Filters\Authentication'
];

// Always applied before every request
public $global = [
'isLoggedIn'               => ['except' => 'login'],
'CodeIgniter\Filters\CSRF' => '*'
];

public $routes = [
'admin/*' => [
'before' => ['isLoggedIn'],
'after' => ['somethingElse']
]
];
}

Yes, this is the one.

On the other hand, I'm just being nit picky. But it's not to dish out anyone. It's to make CI one of the best frameworks out there. Shouldn't we be practicing folders as plural and classes singular? I'd prefer CI4 to be consistent: Apps\Filters\Auth, Configs\Filter. It's a good thing the entire PHP community didn't follow Java samples like org\somefolder\something, com\somefolder\something. A lot of Java developers didn't know that org and com are both organization and company respectively to be used as fully qualified namespace like BCIT\CI\SomeFolders\Something.
Long live CodeIgniter!
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 prezire - 07-10-2016, 10:34 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



Theme © iAndrew 2016 - Forum software by © MyBB