CodeIgniter Forums
Extension of Filters config - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Extension of Filters config (/showthread.php?tid=76489)



Extension of Filters config - oleg1540 - 05-17-2020

Hi,

I'm readng the docs and trying to use filters. Noticed, that we can configure filters in Filters and Routes configs.

https://codeigniter.com/user_guide/incoming/filters.html#filters

We can only set uri pattern for filter, but can't set params for filters. Although, Routes config allows it.

https://codeigniter.com/user_guide/incoming/routing.html?highlight=filter#applying-filters

I think its's good that we can configure filter in routes, but it's some strange, that Routes config give us more availabels for setting filters than Filters config.

May will be expand Filters config something like this?
PHP Code:
public $filters = [
    'role' => [
        'before' => [
            'uri' => ['account/*'],
            'params' => [
 
                1,
 
                2,
                'type' => 'strong',
                'ids' => [12],
            ]
        ]
    ],
]; 

That wiil allow to configure not only uri patterns, but any params, which need for custom filters.
Or like this (with "except uri" pattern):
PHP Code:
public $filters = [
    'role' => [
        'before' => [
            'uri' => ['account/*'],
            'except' => ['account/login'],
            'params' => [...]
        ]
    ],
];