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(); } }