• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filters only for to use in route entries

#1
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

#2
In fact I also have this problem, I am following the rules, declared the alias and I want to use the filter only on the path.


PHP Code:
public $aliases = [
'csrf'    => \CodeIgniter\Filters\CSRF::class,
'toolbar'  => \CodeIgniter\Filters\DebugToolbar::class,
'honeypot' => \CodeIgniter\Filters\Honeypot::class,
'admin-auth' => \App\Filters\FilterApiAuth::class
]; 

PHP Code:
$routes->group('api', ['namespace' => 'App\Api'], function($routes)
{
    $routes->resource('Auth');
    $routes->resource('Ftp',['filter' => 'admin-auth']);
}
); 
Hernan Rodríguez
[email protected]
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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