Ejemplo n.º 1
0
 /**
  * Parse view for exception.
  *
  * @param \Exception $exception
  * @since 0.1.0
  */
 private function parseView($exception)
 {
     if (!$this->resources->getEnviorment()->isSilent()) {
         error_log($exception->getMessage() . " " . $exception->getFile() . "(" . $exception->getLine() . ")");
     }
     $response = new Response();
     $response->setStatusCode(500);
     $response->setContent($exception);
     $this->resources->registerResponse($response);
     $presenter = null;
     try {
         $presenter = $this->resources->getPresenter();
     } catch (ResourcesNotRegisteredException $e) {
         $presenter = $this->findPresenter();
     }
     try {
         $request = $this->resources->getRequest();
     } catch (ResourcesNotRegisteredException $e) {
         $requestConfig = new RequestConfig('', '', $this->resources->getEnviorment(), array('route' => '', 'presenter' => array('class' => ''), 'class' => ''));
         if ($this->resources->getEnviorment()->isSilent()) {
             $request = new RequestTest($this->resources->getUrl(), $this->resources->getEnviorment());
             $request->setConfig($requestConfig);
         } else {
             $session = new Session($this->resources->getEnviorment());
             $request = new Request($requestConfig, $this->resources->getUrl(), $session);
         }
         $this->resources->registerRequest($request);
     }
     if ($presenter) {
         $event = new ExecutePresenterEvent($this->resources->getRequest(), $response);
         $this->eventManager->fire('executePresenter', $event);
         $presenter->render($request->getConfig(), $response);
     }
 }
Ejemplo n.º 2
0
 public function executeRequestTest(RequestTest $request)
 {
     $url = $request->getUrl();
     $this->executeResources->registerUrl($url);
     ob_start();
     try {
         $dispatcher = $this->router->createHttpTestDispatcher($this->executeResources->getEnviorment(), $this->executeResources->getGlobalConfig(), $this->executeResources->getUrl());
         $dispatcher->setRequest($request);
         $dispatcher->execute($this->executeResources, $this->eventManager);
     } catch (\Exception $e) {
         $this->errorHandler->exception($e);
     }
     $content = ob_get_clean();
     ob_flush();
     $this->executeResources->getResponse()->setContent($content);
     return $this->executeResources->getResponse();
 }