コード例 #1
0
ファイル: ErrorWriter.php プロジェクト: vvval/spiral
 /**
  * Write ClientException content into response.
  *
  * @param Request         $request
  * @param Response        $response
  * @param ClientException $exception
  * @return Request
  */
 public function writeException(Request $request, Response $response, ClientException $exception)
 {
     //Has to contain valid http code
     $response = $response->withStatus($exception->getCode());
     if ($request->getHeaderLine('Accept') == 'application/json') {
         //Json got requested
         return $this->writeJson($response, ['status' => $exception->getCode()]);
     }
     if (!$this->config->hasView($exception->getCode())) {
         //We don't or can't render http error view
         return $response;
     }
     $errorPage = $this->views->render($this->config->errorView($exception->getCode()), ['httpConfig' => $this->config, 'request' => $request]);
     $response->getBody()->write($errorPage);
     return $response;
 }
コード例 #2
0
ファイル: Snapshot.php プロジェクト: jwdeitch/components
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if (!empty($this->renderCache)) {
         return $this->renderCache;
     }
     return $this->renderCache = $this->views->render($this->config['view'], ['snapshot' => $this, 'container' => $this->container, 'debugger' => $this->debugger]);
 }
コード例 #3
0
ファイル: Snapshot.php プロジェクト: vvval/spiral
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     if (!empty($this->rendered)) {
         return $this->rendered;
     }
     if (empty($this->config->viewName())) {
         return parent::render();
     }
     return $this->rendered = $this->views->render($this->config->viewName(), ['exception' => $this->getException()]);
 }