Danilo Azevedo
Danilo Azevedo

Reputation: 243

Get current action in CakePHP 3

In CakePHP 2 I could get the current action by using $this->action, but in CakePHP 3.x I can't use this anymore, as it returns the following error:

Error: actionHelper could not be found.

How do I get the current action in CakePHP 3?

Upvotes: 4

Views: 10423

Answers (3)

Felipe Sá
Felipe Sá

Reputation: 61

In CakePHP 3.7 use:

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

Upvotes: 6

bravo-kernel
bravo-kernel

Reputation: 76

Starting from CakePHP 3.6 use non-deprecated $this->request->getParam('action')

Upvotes: 5

Danilo Azevedo
Danilo Azevedo

Reputation: 243

$this->request->actionOR $this->request->params['action'] both works.

Upvotes: 13

Related Questions