Skip to content

Commit

Permalink
BUGFIX: Allow standalone instance of FusionView without request
Browse files Browse the repository at this point in the history
previously the `@package` resolving would always take place, even if not necessary, when all includes are fully specified.
  • Loading branch information
mhsdesign committed Feb 16, 2024
1 parent 2935495 commit 9537cae
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Neos.Fusion/Classes/View/FusionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
Expand All @@ -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();
}
}
Expand Down

0 comments on commit 9537cae

Please sign in to comment.