diff --git a/Classes/Domain/Fusion/PrototypeRepository.php b/Classes/Domain/Fusion/PrototypeRepository.php index 4bf5bd57..e0c8acbc 100644 --- a/Classes/Domain/Fusion/PrototypeRepository.php +++ b/Classes/Domain/Fusion/PrototypeRepository.php @@ -14,6 +14,7 @@ */ use Neos\Flow\Annotations as Flow; +use Neos\Fusion\Core\FusionConfiguration; use Neos\Fusion\Core\Runtime as FusionRuntime; use Neos\Fusion\Core\RuntimeFactory as FusionRuntimeFactory; use Sitegeist\Monocle\Fusion\FusionService; @@ -40,7 +41,9 @@ public function findOneByPrototypeNameInSitePackage( string $sitePackageKey ): ?Prototype { $fusionObjectTree = $this->fusionService->getMergedFusionObjectTreeForSitePackage($sitePackageKey); - + if ($fusionObjectTree instanceof FusionConfiguration) { + $fusionObjectTree = $fusionObjectTree->toArray(); + } if (isset($fusionObjectTree['__prototypes'][$prototypeName])) { $fusionAst = $fusionObjectTree['__prototypes'][$prototypeName]; $fusionRuntime = $this->fusionRuntimeFactory->create($fusionObjectTree); diff --git a/Classes/Fusion/FusionService.php b/Classes/Fusion/FusionService.php index 14bc9514..b507e221 100644 --- a/Classes/Fusion/FusionService.php +++ b/Classes/Fusion/FusionService.php @@ -35,12 +35,11 @@ class FusionService extends NeosFusionService * Returns a merged fusion object tree in the context of the given site-package * * @param string $siteResourcesPackageKey - * @return array The merged object tree as of the given node * @throws \Neos\Neos\Domain\Exception */ - public function getMergedFusionObjectTreeForSitePackage($siteResourcesPackageKey) + public function getMergedFusionObjectTreeForSitePackage($siteResourcesPackageKey): FusionConfiguration { - return $this->getFusionConfigurationForPackageKey($siteResourcesPackageKey)->toArray(); + return $this->getFusionConfigurationForPackageKey($siteResourcesPackageKey); } @@ -76,12 +75,13 @@ public function getFusionConfigurationForPackageKey(string $packageKey): FusionC /** * Get all styleguide objects for the given fusion-ast - * - * @param array $fusionAst - * @return array */ - public function getStyleguideObjectsFromFusionAst($fusionAst) + public function getStyleguideObjectsFromFusionAst(array|FusionConfiguration $fusionAst): array { + if ($fusionAst instanceof FusionConfiguration) { + $fusionAst = $fusionAst->toArray(); + } + $styleguideObjects = []; if ($fusionAst && $fusionAst['__prototypes']) { foreach ($fusionAst['__prototypes'] as $prototypeFullName => $prototypeObject) { diff --git a/Classes/Fusion/FusionView.php b/Classes/Fusion/FusionView.php index 2c54df69..f62f2b70 100644 --- a/Classes/Fusion/FusionView.php +++ b/Classes/Fusion/FusionView.php @@ -14,6 +14,7 @@ */ use Neos\Flow\Annotations as Flow; +use Neos\Fusion\Core\FusionConfiguration; use Neos\Fusion\View\FusionView as BaseFusionView; use Neos\Fusion\Core\Runtime as FusionRuntime; use Neos\Flow\I18n\Locale; @@ -45,8 +46,14 @@ class FusionView extends BaseFusionView */ protected function loadFusion() { - $fusionAst = $this->fusionService->getMergedFusionObjectTreeForSitePackage($this->getOption('packageKey')); - $this->parsedFusion = $fusionAst; + /** @todo remove the switch after Neos 8 support is removed */ + $r = new \ReflectionClass(static::class); + $parsedFusionType = $r->getProperty('parsedFusion')->getType(); + if ($parsedFusionType->getName() === FusionConfiguration::class) { + $this->parsedFusion = $this->fusionService->getMergedFusionObjectTreeForSitePackage($this->getOption('packageKey')); + } else { + $this->parsedFusion = $this->fusionService->getMergedFusionObjectTreeForSitePackage($this->getOption('packageKey'))->toArray(); + } } /**