1

In Zend Framework 1 I can get them by doing:

$this->actionName = $this->getRequest()->getActionName();
$this->controllerName = $this->getRequest()->getControllerName();

In Zend Framework 2 I have no clue. How to obtain the controllerName and actionName?

hakre
  • 193,403
  • 52
  • 435
  • 836
刘小贝
  • 11
  • 1
  • 5

1 Answers1

1

In the controller:

$this->getEvent()->getRouteMatch()->getParam('action', 'NA'); $this->getEvent()->getRouteMatch()->getParam('controller', 'NA');

( Second param is the default value )

michaelbn
  • 7,393
  • 3
  • 33
  • 46