/** * Runs the application * * @return $this */ public function run() { try { // Dispatch the request using the router $this->getRouter()->dispatch($this->getRequest()); } catch (Exception $exception) { // Create event $event = new ExceptionEvent(); $event->setName(ExceptionEvent::EXCEPTION)->setException($exception); // Trigger event $this->getEventManager()->trigger($event); } // Send response $this->getResponse()->sendHeaders()->sendContent(); return $this; }