![]() |
Filter run order - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Filter run order (/showthread.php?tid=77449) |
Filter run order - ogomez - 09-02-2020 I have a filter being ran off of a route. Is there a way to make sure other filters run before the filter on the route? PHP Code: public $aliases = [ The problem I'm having is that options and authenticate filters are running after the permission filter. Is there a way to make sure my options and authenticate filters run first? Thanks in advance. RE: Filter run order - chenzen - 09-03-2020 (09-02-2020, 06:17 PM)ogomez Wrote: I have a filter being ran off of a route. Is there a way to make sure other filters run before the filter on the route? Only one filter runs per route, so redesign the permission filter to run any code that it depends on first. RE: Filter run order - Gary - 09-06-2020 I take it that your permission filter runs on every call... surely if you simply remove the filter option and use: $routes->get('admin', 'Admin::index'); it would work in the desired manner? If it's not, then you could stop the permissions filter from where it's not wanted using: 'permission' => ['except' => ['Index/*',... in your Filter's $globals variable. |