From 9537cae9d58d5c16ef54de140044d823dffdb281 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:08:56 +0100 Subject: [PATCH] BUGFIX: Allow standalone instance of `FusionView` without request previously the `@package` resolving would always take place, even if not necessary, when all includes are fully specified. --- Neos.Fusion/Classes/View/FusionView.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Neos.Fusion/Classes/View/FusionView.php b/Neos.Fusion/Classes/View/FusionView.php index c1ba4337296..bf983346f4f 100644 --- a/Neos.Fusion/Classes/View/FusionView.php +++ b/Neos.Fusion/Classes/View/FusionView.php @@ -224,10 +224,13 @@ protected function getMergedFusionObjectTree(): FusionConfiguration */ public function getFusionPathPatterns(): array { - $packageKey = $this->getPackageKey(); $fusionPathPatterns = array_map( - function ($fusionPathPattern) use ($packageKey) { - return str_replace('@package', $packageKey, $fusionPathPattern); + function ($fusionPathPattern) { + if (!str_contains($fusionPathPattern, '@package')) { + return $fusionPathPattern; + } + + return str_replace('@package', $this->getPackageKey(), $fusionPathPattern); }, $this->getOption('fusionPathPatterns') ); @@ -247,8 +250,10 @@ protected function getPackageKey() if ($packageKey !== null) { return $packageKey; } else { - /** @var $request ActionRequest */ - $request = $this->controllerContext->getRequest(); + $request = $this->controllerContext?->getRequest(); + if (!$request) { + throw new \RuntimeException(sprintf('To resolve the @package in all fusionPathPatterns, either packageKey has to be specified, or the current request be available.')); + } return $request->getControllerPackageKey(); } }