1414
1515namespace Neos \Neos \View ;
1616
17- use Neos \ContentRepository \Core \NodeType \NodeTypeManager ;
1817use Neos \ContentRepository \Core \Projection \ContentGraph \Filter \FindClosestNodeFilter ;
1918use Neos \ContentRepository \Core \Projection \ContentGraph \Node ;
2019use Neos \ContentRepositoryRegistry \ContentRepositoryRegistry ;
@@ -56,8 +55,6 @@ class FusionView extends AbstractView
5655 #[Flow \Inject]
5756 protected RenderingModeService $ renderingModeService ;
5857
59- protected NodeTypeManager $ nodeTypeManager ;
60-
6158 /**
6259 * Via {@see assign} request using the "request" key,
6360 * will be available also as Fusion global in the runtime.
@@ -75,19 +72,11 @@ public function render(): ResponseInterface|StreamInterface
7572 {
7673 $ currentNode = $ this ->getCurrentNode ();
7774
78- $ 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-
75+ $ currentSiteNode = $ this ->getCurrentSiteNode ();
8576 $ fusionRuntime = $ this ->getFusionRuntime ($ currentSiteNode );
8677
8778 $ this ->setFallbackRuleFromDimension ($ currentNode ->dimensionSpacePoint );
8879
89- $ this ->nodeTypeManager = $ this ->contentRepositoryRegistry ->get ($ subgraph ->getContentRepositoryId ())->getNodeTypeManager ();
90-
9180 return $ fusionRuntime ->renderEntryPathWithContext ($ this ->fusionPath , [
9281 'node ' => $ currentNode ,
9382 'documentNode ' => $ this ->getClosestDocumentNode ($ currentNode ) ?: $ currentNode ,
@@ -170,8 +159,10 @@ public function getFusionPath()
170159
171160 protected function getClosestDocumentNode (Node $ node ): ?Node
172161 {
162+ $ nodeTypeManager = $ this ->contentRepositoryRegistry ->get ($ node ->contentRepositoryId )->getNodeTypeManager ();
163+
173164 // Skip expensive subgraph lookup if the node is already a document node
174- if ($ this -> nodeTypeManager ->getNodeType ($ node ->nodeTypeName )?->isOfType(NodeTypeNameFactory::NAME_DOCUMENT )) {
165+ if ($ nodeTypeManager ->getNodeType ($ node ->nodeTypeName )?->isOfType(NodeTypeNameFactory::NAME_DOCUMENT )) {
175166 return $ node ;
176167 }
177168 return $ this ->contentRepositoryRegistry ->subgraphForNode ($ node )
@@ -184,11 +175,20 @@ protected function getClosestDocumentNode(Node $node): ?Node
184175 */
185176 protected function getCurrentSiteNode (): Node
186177 {
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 );
178+ $ currentSiteNode = $ this ->variables ['site ' ] ?? null ;
179+ if (!$ currentSiteNode instanceof Node) {
180+ $ currentNode = $ this ->getCurrentNode ();
181+ $ subgraph = $ this ->contentRepositoryRegistry ->subgraphForNode ($ currentNode );
182+ $ currentSiteNode = $ subgraph ->findClosestNode (
183+ $ currentNode ->aggregateId ,
184+ FindClosestNodeFilter::create (nodeTypes: NodeTypeNameFactory::NAME_SITE )
185+ );
186+ $ this ->assign ('site ' , $ currentSiteNode );
190187 }
191- return $ currentNode ;
188+ if (!$ currentSiteNode ) {
189+ throw new \RuntimeException ('No site node found! ' , 1697053346 );
190+ }
191+ return $ currentSiteNode ;
192192 }
193193
194194 /**
0 commit comments