1.) MvcEvent::EVENT_BOOTSTRAP
returns: Zend\Mvc\Application
a.) MvcEvent::EVENT_ROUTE
Returns: Zend\Mvc\Application
b.) MvcEvent:EVENT_DISPATCH
Returns: Zend\Mvc\Controller\AbstractController
c.) MvcEvent:EVENT_RENDER
Returns: Zend\Mvc\Application
d.) MvcEvent:EVENT_FINISH
Returns: Zend\Mvc\Application
You will usually attach to an event inside onBootstrap($e) in Module.php
//Module.php
namespace SomeModule;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap($e)
{
$e->getName(); // returns MvcEvent::EVENT_BOOTSTRAP
$e->getTarget(); // returns Zend\Mvc\Application
// retrieves the Event Manager within Bootstrap
$em = $e->getApplication()->getEventManager();
$em->attach(MvcEvent::EVENT_ROUTE, function ($e) {
$e->getName(); // returns MvcEvent::EVENT_ROUTE
$e->getTarget(); // returns Zend\Mvc\Application
}
$em->attach(MvcEvent::EVENT_DISPATCH, function ($e) {
$e->getName(); // returns MvcEvent::EVENT_DISPATCH
$e->getTarget(); // returns Zend\Mvc\Controller\AbstractController
}
$em->attach(MvcEvent::EVENT_RENDER, function ($e) {
$e->getName(); // returns MvcEvent::EVENT_RENDER
$e->getTarget(); // returns Zend\Mvc\Application
}
$em->attach(MvcEvent::EVENT_FINISH, function ($e) {
$e->getName(); // returns MvcEvent::EVENT_FINISH
$e->getTarget(); // returns Zend\Mvc\Application
}
}
}
It is only normal to return Zend\Mvc\Application as the object itself is being manipulated in the application process.