Skip to content

Commit

Permalink
Throw NotAcceptableHttpException if template request format not exists (
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKoerner authored Jun 28, 2024
1 parent 43ea998 commit 343d441
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Controller/WebsiteArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
use Twig\Environment;

/**
Expand Down Expand Up @@ -62,6 +63,10 @@ protected function renderArticle(
$requestFormat = $request->getRequestFormat();
$viewTemplate = $view . '.' . $requestFormat . '.twig';

if (!$this->container->get('twig')->getLoader()->exists($viewTemplate)) {
throw new NotAcceptableHttpException(\sprintf('Page does not exist in "%s" format.', $requestFormat));
}

$content = $this->resolveArticle($object, $pageNumber);

$parameters = $this->container->get('sulu_website.resolver.parameter')->resolve(
Expand Down

0 comments on commit 343d441

Please sign in to comment.