Ejemplo n.º 1
0
 public function render(OuzoExceptionData $exceptionData, $viewName)
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $errorMessage = $exceptionData->getMessage();
     $errorTrace = $exceptionData->getStackTrace();
     Logger::getLogger(__CLASS__)->error($exceptionData->getOriginalMessage());
     Logger::getLogger(__CLASS__)->error(Objects::toString($errorTrace));
     $this->clearOutputBuffers();
     header($exceptionData->getHeader());
     $responseType = ResponseTypeResolve::resolve();
     header('Content-type: ' . $responseType);
     $additionalHeaders = $exceptionData->getAdditionalHeaders();
     array_walk($additionalHeaders, function ($header) {
         header($header);
     });
     /** @noinspection PhpIncludeInspection */
     require ViewPathResolver::resolveViewPath($viewName, $responseType);
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function shouldReturnHtmlForUnsupportedAcceptAndNoRequestContentType()
 {
     //given
     $_SERVER['HTTP_ACCEPT'] = 'application/unsupported';
     ContentType::set(null);
     //when
     $resolved = ResponseTypeResolve::resolve();
     //then
     $this->assertEquals('text/html', $resolved);
 }
Ejemplo n.º 3
0
 private function needPrettyHandler()
 {
     $isHtmlResponse = ResponseTypeResolve::resolve() == "text/html";
     return $isHtmlResponse && !Uri::isAjax();
 }