From b737c01916022cb8ff231230d274974633e7d48a Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 16 Feb 2024 22:47:21 +0100 Subject: [PATCH] TASK: Runtime `renderResponse` unwrap `RuntimeException` itself Previously the pattern was that the utmost caller of the runtime would unwrap the exception. To simplify this, as the runtime now has a single entry point, we add this behaviour into the runtime. --- Neos.Fusion/Classes/Core/Runtime.php | 3 +++ Neos.Fusion/Classes/View/FusionView.php | 6 +----- Neos.Neos/Classes/View/FusionView.php | 16 +++++----------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Neos.Fusion/Classes/Core/Runtime.php b/Neos.Fusion/Classes/Core/Runtime.php index 8f188e0b83b..c2f8ae38741 100644 --- a/Neos.Fusion/Classes/Core/Runtime.php +++ b/Neos.Fusion/Classes/Core/Runtime.php @@ -277,6 +277,9 @@ public function renderResponse(string $fusionPath, array $contextArray): Respons return $this->withSimulatedLegacyControllerContext(function () use ($fusionPath) { try { $output = $this->render($fusionPath); + } catch (RuntimeException $exception) { + // unwrap the FusionRuntimeException + throw $exception->getPrevious(); } finally { $this->popContext(); } diff --git a/Neos.Fusion/Classes/View/FusionView.php b/Neos.Fusion/Classes/View/FusionView.php index bdc4413e113..36d4fe6ae5c 100644 --- a/Neos.Fusion/Classes/View/FusionView.php +++ b/Neos.Fusion/Classes/View/FusionView.php @@ -149,11 +149,7 @@ public function render() $this->initializeFusionRuntime(); if ($this->getOption('renderHttpResponse') === true) { - try { - return $this->fusionRuntime->renderResponse($this->getFusionPathForCurrentRequest(), $this->variables); - } catch (RuntimeException $exception) { - throw $exception->getPrevious(); - } + return $this->fusionRuntime->renderResponse($this->getFusionPathForCurrentRequest(), $this->variables); } else { try { $this->fusionRuntime->pushContextArray($this->variables); diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index d3142635911..d86ef54c240 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -14,7 +14,6 @@ namespace Neos\Neos\View; -use GuzzleHttp\Psr7\Message; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; @@ -24,7 +23,6 @@ use Neos\Fusion\Core\FusionGlobals; use Neos\Fusion\Core\Runtime; use Neos\Fusion\Core\RuntimeFactory; -use Neos\Fusion\Exception\RuntimeException; use Neos\Neos\Domain\Model\RenderingMode; use Neos\Neos\Domain\Repository\SiteRepository; use Neos\Neos\Domain\Service\FusionService; @@ -74,15 +72,11 @@ public function render(): ResponseInterface $fusionRuntime = $this->getFusionRuntime($currentSiteNode); - try { - return $fusionRuntime->renderResponse($this->fusionPath, [ - 'node' => $currentNode, - 'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode, - 'site' => $currentSiteNode - ]); - } catch (RuntimeException $exception) { - throw $exception->getPrevious() ?: $exception; - } + return $fusionRuntime->renderResponse($this->fusionPath, [ + 'node' => $currentNode, + 'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode, + 'site' => $currentSiteNode + ]); } /**