Zend\Mvc\Application::bootstrap PHP Method

bootstrap() public method

Defines and binds the MvcEvent, and passes it the request, response, and router. Attaches the ViewManager as a listener. Triggers the bootstrap event.
public bootstrap ( array $listeners = [] ) : Application
$listeners array List of listeners to attach.
return Application
    public function bootstrap(array $listeners = [])
    {
        $serviceManager = $this->serviceManager;
        $events = $this->events;
        // Setup default listeners
        $listeners = array_unique(array_merge($this->defaultListeners, $listeners));
        foreach ($listeners as $listener) {
            $serviceManager->get($listener)->attach($events);
        }
        // Setup MVC Event
        $this->event = $event = new MvcEvent();
        $event->setName(MvcEvent::EVENT_BOOTSTRAP);
        $event->setTarget($this);
        $event->setApplication($this);
        $event->setRequest($this->request);
        $event->setResponse($this->response);
        $event->setRouter($serviceManager->get('Router'));
        // Trigger bootstrap events
        $events->triggerEvent($event);
        return $this;
    }

Usage Example

Example #1
0
 protected function getApplication()
 {
     if (null === $this->application) {
         $this->application = $this->getServiceManager()->get('Application');
         $this->application->bootstrap();
     }
     return $this->application;
 }
All Usage Examples Of Zend\Mvc\Application::bootstrap