获取CakePHP 3中的当前操作

Dan*_*edo 3 php controller cakephp cakephp-3.0

在CakePHP 2中我可以通过使用获取当前操作$this->action,但在CakePHP 3.x中我不能再使用它了,因为它返回以下错误:

Error: actionHelper could not be found.
Run Code Online (Sandbox Code Playgroud)

如何在CakePHP 3中获取当前操作?

Dan*_*edo 12

$this->request->action$this->request->params['action']两者都有效.


小智 5

从 CakePHP 3.6 开始使用非弃用 $this->request->getParam('action')


小智 5

在 CakePHP 3.7 中使用:

$this->getRequest()->getParam('action')