Zend\Mvc\MvcEvent::getApplication PHP Method

getApplication() public method

Get application instance
public getApplication ( ) : Zend\Mvc\ApplicationInterface
return Zend\Mvc\ApplicationInterface
    public function getApplication()
    {
        return $this->application;
    }

Usage Example

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $serviceManager = $e->getApplication()->getServiceManager();
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'handleException'));
     //set the global exception handler
     //set_exception_handler( array( $this, 'handleException' ) );
     // Disable layout for ajax requests
     // $eventManager->attach(MvcEvent::EVENT_DISPATCH, function ($e)
     // {
     // IF its an AJAX request & its not in JSON Model form yet
     // then it has been JMS serialized & thus just needs to be printed
     // if ($e->getRequest()->isXmlHttpRequest() && ! ($result instanceof \Zend\View\Model\JsonModel) ) {
     //$viewModel = new \Zend\View\Model\ViewModel(array(
     //    'content' => $result,
     //));
     //$viewModel->setTemplate('layout/empty');
     //$e->setViewModel($viewModel);
     // }
     // });
     // Ensuring services are available to be called in the application model
     // by setting the registry into a static variable
     // This enforces usage of service locator pattern instead of dependency injection
     \Application\Model\CommonServiceMutatorTrait::setServiceLocator($serviceManager);
 }
All Usage Examples Of Zend\Mvc\MvcEvent::getApplication