public static function resolve()
{
$accept = array_keys(RequestHeaders::accept()) ?: array('*/*');
$supported = array('application/json' => 'application/json', 'application/xml' => 'application/xml', 'application/*' => 'application/json', 'text/html' => 'text/html', 'text/*' => 'text/html');
$intersection = array_intersect($accept, array_keys($supported));
if ($intersection) {
return $supported[Arrays::first($intersection)];
}
return Arrays::getValue($supported, ContentType::value(), 'text/html');
}
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); }