Skip to content

Commit

Permalink
TASK: Adjust to interface changes from neos/neos-development-collecti…
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed Sep 8, 2023
1 parent 5b33c35 commit 1ca8ac8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Classes/Domain/Fusion/PrototypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions Classes/Fusion/FusionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions Classes/Fusion/FusionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down

0 comments on commit 1ca8ac8

Please sign in to comment.