Skip to content

Commit

Permalink
Merge pull request #35 from madapaja/fix-redirect-html
Browse files Browse the repository at this point in the history
Fix redirect html
  • Loading branch information
koriym authored Jun 28, 2019
2 parents 6c73406 + bcb7072 commit 1bb996e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/TwigRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ public function render(ResourceObject $ro)

if ($this->isNoContent($ro)) {
$ro->view = '';
} elseif ($this->isRedirect($ro)) {

return $ro->view;
}
if ($this->isRedirect($ro)) {
$ro->view = $this->renderRedirectView($ro);
} else {
$ro->view = $this->renderView($ro);

return $ro->view;
}
$ro->view = $this->renderView($ro);

return $ro->view;
}

private function setContentType(ResourceObject $ro)
{
if (! isset($ro->headers['content-type'])) {
$ro->headers['content-type'] = 'text/html; charset=utf-8';
if (! isset($ro->headers['Content-Type'])) {
$ro->headers['Content-Type'] = 'text/html; charset=utf-8';
}
}

Expand All @@ -84,9 +88,11 @@ private function renderView(ResourceObject $ro)

private function renderRedirectView(ResourceObject $ro)
{
$url = $ro->headers['Location'];

return $this->twig->render($this->redirectPage, ['url' => $url]);
try {
return $this->twig->render($this->redirectPage, ['url' => $ro->headers['Location']]);
} catch (LoaderError $e) {
return '';
}
}

/**
Expand Down

0 comments on commit 1bb996e

Please sign in to comment.