Welcome Guest, Not a member yet? Register   Sign In
Filters only for to use in route entries
#1

(This post was last modified: 03-11-2020, 11:55 PM by aybarsm.)

Hello all,

I am first time user of CodeIgniter started directly with 4.0.2. Have to say, congrats to everyone who was involved and of course thank you all.

So my question:
I would like to declare a filter in order to use with just in Routes.php like below. Even though I have declared my filter alias in Filters.php, it seems that filter does not load without declaring it in $filters.

I don't want to declare it in $filters because I have clashing routes and {locale}/ master route which is causing a lot of trouble to me already and also causing a lot trouble with regex-like $filters

Is there any way to achieve to do this? Should I try something from an unusual way? I am 'follow the rules' guy, so I thought maybe I am missing something and wanted to ask.

Filters.php entry:
Code:
public $aliases = [
    'auth-client' => \App\Filters\AuthClient::class,
    'csrf'     => \CodeIgniter\Filters\CSRF::class,
    'toolbar'  => \CodeIgniter\Filters\DebugToolbar::class,
    'honeypot' => \CodeIgniter\Filters\Honeypot::class,
];

public $filters = [];



Routes.php entry:

Code:
$routes->group('client', ['filter'=>'auth-client'], function($routes) {
    $routes->get('/', 'Client::dashboard', ['as'=>'dashboardClient']);
});
Reply


Messages In This Thread
Filters only for to use in route entries - by aybarsm - 03-11-2020, 02:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB