Zend\Mvc\Application::setEventManager PHP Method

setEventManager() public method

Set the event manager instance
public setEventManager ( Zend\EventManager\EventManagerInterface $eventManager ) : Application
$eventManager Zend\EventManager\EventManagerInterface
return Application
    public function setEventManager(EventManagerInterface $eventManager)
    {
        $eventManager->setIdentifiers([__CLASS__, get_class($this)]);
        $this->events = $eventManager;
        return $this;
    }

Usage Example

Example #1
0
 public function testOnBootstrap()
 {
     $event = new MvcEvent();
     $application = new Application([], Bootstrap::getServiceManager());
     $em = new EventManager();
     $application->setEventManager($em);
     $event->setApplication($application);
     $isConsole = Console::isConsole();
     Console::overrideIsConsole(false);
     $this->module->onBootstrap($event);
     Console::overrideIsConsole($isConsole);
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH));
     $this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER));
 }