diff --git a/src/Controller/IframeController.php b/src/Controller/IframeController.php index 6245772..98dc69a 100644 --- a/src/Controller/IframeController.php +++ b/src/Controller/IframeController.php @@ -16,6 +16,7 @@ use IQ2i\StoriaBundle\View\ViewBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Profiler\Profiler; use Twig\Environment; @@ -33,8 +34,20 @@ public function __invoke(Request $request, ?Profiler $profiler): Response $profiler->disable(); } + $view = $this->viewBuilder->createFromRequest($request); + if (null === $view) { + throw new NotFoundHttpException(); + } + + $content = $view->getCurrentVariant()->getHtmlContent(); + + $pos = strripos((string) $content, '
- {% block body %} - {{ view.currentVariant.htmlContent|raw }} - {% endblock %} + {% block body %}{{ content|raw }}{% endblock %}'); + if (false !== $pos) { + return new Response($content); + } + return new Response($this->twig->render('@IQ2iStoria/iframe.html.twig', [ - 'view' => $this->viewBuilder->createFromRequest($request), + 'content' => $content, ])); } } diff --git a/templates/iframe.html.twig b/templates/iframe.html.twig index 59d2527..50af597 100644 --- a/templates/iframe.html.twig +++ b/templates/iframe.html.twig @@ -1,19 +1,19 @@ -{# @var view \IQ2i\StoriaBundle\View\Dto\View #} -
+ + + + {% block stylesheets %}{% endblock %} {% block javascripts %}{% endblock %}