This question already has an answer here:
I wanted to execute a method for each page in my Zend 2 application. Thus, i added it to Application
's Module.php
onBootstrap method.
Now i need to know which controller is being called and rest of the parameters (action, id ...).
public function onBootstrap(MvcEvent $e)
{
$controllerName = ''; //how to get ?
$actionName = ''; //how to get ?
$id = ''; //how to get ?
...
myMethod($controllerName, $actionName, $id);
}
</div>
Solution - How to get parameters from Route in ZF2 module? (class Module, function onBootstrap())
class Module {
public function onBootstrap(MvcEvent $e) {
$e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH,
function($e){
var_dump($e->getRouteMatch());
exit;
}
);
}
}