CodeIgniter Forums
Codeigniter 3 fetch_method() equivalent in CI4 - 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: Codeigniter 3 fetch_method() equivalent in CI4 (/showthread.php?tid=81574)



Codeigniter 3 fetch_method() equivalent in CI4 - ChicagoPhil - 03-19-2022

Is there an equivalent method to get the method that was called in the current controller class that CI3 had that was called fetch_method()? The docs are a bit overwhelming right now because I'm not used to a lot of this stuff that's included in this framework. I used get_class() to get the class but I haven't found the easy way to get the method just yet. I'm still searching the docs but I know it has to be somewhere.

Thanks forĀ  your time


RE: Codeigniter 3 fetch_method() equivalent in CI4 - kenjis - 03-19-2022

PHP Code:
$router = \Config\Services::router();
$method $router->methodName(); 



RE: Codeigniter 3 fetch_method() equivalent in CI4 - ChicagoPhil - 03-19-2022

I found the method in the Router Class. It's called methodName() now. Of course I got the idea where to find it right after I posted the question.

(03-19-2022, 07:24 PM)kenjis Wrote:
PHP Code:
$router = \Config\Services::router();
$method $router->methodName(); 

You're quick! Thank You!