Skip to content

Commit c5b1f01

Browse files
committed
BUGFIX: Skip site node query in FusionView if node is already available
We use the existing method to get the site node and fall back to the query if necessary.
1 parent 0570af6 commit c5b1f01

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Neos.Neos/Classes/View/FusionView.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ public function render(): ResponseInterface|StreamInterface
7676
$currentNode = $this->getCurrentNode();
7777

7878
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($currentNode);
79-
$currentSiteNode = $subgraph->findClosestNode($currentNode->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
80-
81-
if (!$currentSiteNode) {
82-
throw new \RuntimeException('No site node found!', 1697053346);
83-
}
84-
79+
$currentSiteNode = $this->getCurrentSiteNode();
8580
$fusionRuntime = $this->getFusionRuntime($currentSiteNode);
8681

8782
$this->setFallbackRuleFromDimension($currentNode->dimensionSpacePoint);
@@ -184,11 +179,20 @@ protected function getClosestDocumentNode(Node $node): ?Node
184179
*/
185180
protected function getCurrentSiteNode(): Node
186181
{
187-
$currentNode = $this->variables['site'] ?? null;
188-
if (!$currentNode instanceof Node) {
189-
throw new Exception('FusionView needs a variable \'site\' set with a Node object.', 1538996432);
182+
$currentSiteNode = $this->variables['site'] ?? null;
183+
if (!$currentSiteNode instanceof Node) {
184+
$currentNode = $this->getCurrentNode();
185+
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($currentNode);
186+
$currentSiteNode = $subgraph->findClosestNode(
187+
$currentNode->aggregateId,
188+
FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE)
189+
);
190+
$this->assign('site', $currentSiteNode);
190191
}
191-
return $currentNode;
192+
if (!$currentSiteNode) {
193+
throw new \RuntimeException('No site node found!', 1697053346);
194+
}
195+
return $currentSiteNode;
192196
}
193197

194198
/**

0 commit comments

Comments
 (0)