14
14
15
15
namespace Neos \Neos \Controller \Frontend ;
16
16
17
- use Neos \ContentRepository \Core \ContentRepository ;
18
17
use Neos \ContentRepository \Core \Projection \ContentGraph \ContentGraphWithRuntimeCaches \ContentSubgraphWithRuntimeCaches ;
19
18
use Neos \ContentRepository \Core \Projection \ContentGraph \ContentGraphWithRuntimeCaches \InMemoryCache ;
20
19
use Neos \ContentRepository \Core \Projection \ContentGraph \ContentSubgraphInterface ;
25
24
use Neos \ContentRepository \Core \Projection \ContentGraph \Subtree ;
26
25
use Neos \ContentRepository \Core \Projection \ContentGraph \VisibilityConstraints ;
27
26
use Neos \ContentRepository \Core \SharedModel \Node \NodeAggregateId ;
27
+ use Neos \ContentRepository \Core \SharedModel \Node \NodeAddress ;
28
28
use Neos \ContentRepositoryRegistry \ContentRepositoryRegistry ;
29
29
use Neos \Flow \Annotations as Flow ;
30
30
use Neos \Flow \Mvc \Controller \ActionController ;
39
39
use Neos \Neos \Domain \Service \RenderingModeService ;
40
40
use Neos \Neos \FrontendRouting \Exception \InvalidShortcutException ;
41
41
use Neos \Neos \FrontendRouting \Exception \NodeNotFoundException ;
42
- use Neos \Neos \FrontendRouting \NodeAddress ;
43
- use Neos \Neos \FrontendRouting \NodeAddressFactory ;
44
42
use Neos \Neos \FrontendRouting \NodeShortcutResolver ;
45
- use Neos \Neos \FrontendRouting \NodeUriBuilder ;
43
+ use Neos \Neos \FrontendRouting \NodeUriBuilderFactory ;
46
44
use Neos \Neos \FrontendRouting \SiteDetection \SiteDetectionResult ;
47
45
use Neos \Neos \Utility \NodeTypeWithFallbackProvider ;
48
46
use Neos \Neos \View \FusionView ;
@@ -106,6 +104,9 @@ class NodeController extends ActionController
106
104
#[Flow \InjectConfiguration(path: "frontend.shortcutRedirectHttpStatusCode " , package: "Neos.Neos " )]
107
105
protected int $ shortcutRedirectHttpStatusCode ;
108
106
107
+ #[Flow \Inject]
108
+ protected NodeUriBuilderFactory $ nodeUriBuilderFactory ;
109
+
109
110
/**
110
111
* @param string $node
111
112
* @throws NodeNotFoundException
@@ -130,21 +131,14 @@ public function previewAction(string $node): void
130
131
$ siteDetectionResult = SiteDetectionResult::fromRequest ($ this ->request ->getHttpRequest ());
131
132
$ contentRepository = $ this ->contentRepositoryRegistry ->get ($ siteDetectionResult ->contentRepositoryId );
132
133
133
- $ nodeAddress = NodeAddressFactory:: create ( $ contentRepository )-> createFromUriString ($ node );
134
+ $ nodeAddress = NodeAddress:: fromJsonString ($ node );
134
135
135
136
$ subgraph = $ contentRepository ->getContentGraph ($ nodeAddress ->workspaceName )->getSubgraph (
136
137
$ nodeAddress ->dimensionSpacePoint ,
137
138
$ visibilityConstraints
138
139
);
139
140
140
- $ site = $ subgraph ->findClosestNode ($ nodeAddress ->nodeAggregateId , FindClosestNodeFilter::create (nodeTypes: NodeTypeNameFactory::NAME_SITE ));
141
- if ($ site === null ) {
142
- throw new NodeNotFoundException ("TODO: SITE NOT FOUND; should not happen (for address " . $ nodeAddress );
143
- }
144
-
145
- $ this ->fillCacheWithContentNodes ($ nodeAddress ->nodeAggregateId , $ subgraph );
146
-
147
- $ nodeInstance = $ subgraph ->findNodeById ($ nodeAddress ->nodeAggregateId );
141
+ $ nodeInstance = $ subgraph ->findNodeById ($ nodeAddress ->aggregateId );
148
142
149
143
if (is_null ($ nodeInstance )) {
150
144
throw new NodeNotFoundException (
@@ -153,12 +147,19 @@ public function previewAction(string $node): void
153
147
);
154
148
}
155
149
150
+ $ site = $ subgraph ->findClosestNode ($ nodeAddress ->aggregateId , FindClosestNodeFilter::create (nodeTypes: NodeTypeNameFactory::NAME_SITE ));
151
+ if ($ site === null ) {
152
+ throw new NodeNotFoundException ("TODO: SITE NOT FOUND; should not happen (for identity " . $ nodeAddress ->toJson ());
153
+ }
154
+
155
+ $ this ->fillCacheWithContentNodes ($ nodeAddress ->aggregateId , $ subgraph );
156
+
156
157
if (
157
158
$ this ->getNodeType ($ nodeInstance )->isOfType (NodeTypeNameFactory::NAME_SHORTCUT )
158
159
&& !$ renderingMode ->isEdit
159
160
&& $ nodeAddress ->workspaceName ->isLive () // shortcuts are only resolvable for the live workspace
160
161
) {
161
- $ this ->handleShortcutNode ($ nodeAddress, $ contentRepository );
162
+ $ this ->handleShortcutNode ($ nodeAddress );
162
163
}
163
164
164
165
$ this ->view ->setOption ('renderingModeName ' , $ renderingMode ->name );
@@ -192,33 +193,33 @@ public function previewAction(string $node): void
192
193
*/
193
194
public function showAction (string $ node ): void
194
195
{
195
- $ siteDetectionResult = SiteDetectionResult:: fromRequest ( $ this -> request -> getHttpRequest () );
196
- $ contentRepository = $ this -> contentRepositoryRegistry -> get ( $ siteDetectionResult -> contentRepositoryId );
196
+ $ nodeAddress = NodeAddress:: fromJsonString ( $ node );
197
+ unset( $ node );
197
198
198
- $ nodeAddress = NodeAddressFactory::create ($ contentRepository )->createFromUriString ($ node );
199
- if (!$ nodeAddress ->isInLiveWorkspace ()) {
199
+ if (!$ nodeAddress ->workspaceName ->isLive ()) {
200
200
throw new NodeNotFoundException ('The requested node isn \'t accessible to the current user ' , 1430218623 );
201
201
}
202
202
203
+ $ contentRepository = $ this ->contentRepositoryRegistry ->get ($ nodeAddress ->contentRepositoryId );
203
204
$ subgraph = $ contentRepository ->getContentGraph ($ nodeAddress ->workspaceName )->getSubgraph (
204
205
$ nodeAddress ->dimensionSpacePoint ,
205
206
VisibilityConstraints::frontend ()
206
207
);
207
208
208
- $ nodeInstance = $ subgraph ->findNodeById ($ nodeAddress ->nodeAggregateId );
209
+ $ nodeInstance = $ subgraph ->findNodeById ($ nodeAddress ->aggregateId );
209
210
if ($ nodeInstance === null ) {
210
- throw new NodeNotFoundException (sprintf ('The cached node address for this uri could not be resolved. Possibly you have to flush the "Flow_Mvc_Routing_Route" cache. %s ' , $ nodeAddress ), 1707300738 );
211
+ throw new NodeNotFoundException (sprintf ('The cached node address for this uri could not be resolved. Possibly you have to flush the "Flow_Mvc_Routing_Route" cache. %s ' , $ nodeAddress-> toJson () ), 1707300738 );
211
212
}
212
213
213
- $ site = $ subgraph ->findClosestNode ($ nodeAddress ->nodeAggregateId , FindClosestNodeFilter::create (nodeTypes: NodeTypeNameFactory::NAME_SITE ));
214
+ $ site = $ subgraph ->findClosestNode ($ nodeAddress ->aggregateId , FindClosestNodeFilter::create (nodeTypes: NodeTypeNameFactory::NAME_SITE ));
214
215
if ($ site === null ) {
215
- throw new NodeNotFoundException (sprintf ('The site node of %s could not be resolved. ' , $ nodeAddress ), 1707300861 );
216
+ throw new NodeNotFoundException (sprintf ('The site node of %s could not be resolved. ' , $ nodeAddress-> toJson () ), 1707300861 );
216
217
}
217
218
218
- $ this ->fillCacheWithContentNodes ($ nodeAddress ->nodeAggregateId , $ subgraph );
219
+ $ this ->fillCacheWithContentNodes ($ nodeAddress ->aggregateId , $ subgraph );
219
220
220
221
if ($ this ->getNodeType ($ nodeInstance )->isOfType (NodeTypeNameFactory::NAME_SHORTCUT )) {
221
- $ this ->handleShortcutNode ($ nodeAddress, $ contentRepository );
222
+ $ this ->handleShortcutNode ($ nodeAddress );
222
223
}
223
224
224
225
$ this ->view ->setOption ('renderingModeName ' , RenderingMode::FRONTEND );
@@ -266,31 +267,31 @@ protected function overrideViewVariablesFromInternalArguments()
266
267
/**
267
268
* Handles redirects to shortcut targets of nodes in the live workspace.
268
269
*
269
- * @param NodeAddress $nodeAddress
270
270
* @throws NodeNotFoundException
271
271
* @throws \Neos\Flow\Mvc\Exception\StopActionException
272
272
*/
273
- protected function handleShortcutNode (NodeAddress $ nodeAddress, ContentRepository $ contentRepository ): void
273
+ protected function handleShortcutNode (NodeAddress $ nodeAddress ): void
274
274
{
275
275
try {
276
- $ resolvedTarget = $ this ->nodeShortcutResolver ->resolveShortcutTarget ($ nodeAddress, $ contentRepository );
276
+ $ resolvedTarget = $ this ->nodeShortcutResolver ->resolveShortcutTarget ($ nodeAddress );
277
277
} catch (InvalidShortcutException $ e ) {
278
278
throw new NodeNotFoundException (sprintf (
279
- 'The shortcut node target of node "%s" could not be resolved: %s ' ,
280
- $ nodeAddress ,
279
+ 'The shortcut node target of node %s could not be resolved: %s ' ,
280
+ $ nodeAddress-> toJson () ,
281
281
$ e ->getMessage ()
282
282
), 1430218730 , $ e );
283
283
}
284
284
if ($ resolvedTarget instanceof NodeAddress) {
285
- if ($ resolvedTarget === $ nodeAddress ) {
285
+ if ($ nodeAddress-> equals ( $ resolvedTarget ) ) {
286
286
return ;
287
287
}
288
288
try {
289
- $ resolvedUri = NodeUriBuilder::fromRequest ($ this ->request )->uriFor ($ nodeAddress );
289
+ $ resolvedUri = $ this ->nodeUriBuilderFactory ->forActionRequest ($ this ->request )
290
+ ->uriFor ($ nodeAddress );
290
291
} catch (NoMatchingRouteException $ e ) {
291
292
throw new NodeNotFoundException (sprintf (
292
- 'The shortcut node target of node "%s" could not be resolved: %s ' ,
293
- $ nodeAddress ,
293
+ 'The shortcut node target of node %s could not be resolved: %s ' ,
294
+ $ nodeAddress-> toJson () ,
294
295
$ e ->getMessage ()
295
296
), 1599670695 , $ e );
296
297
}
0 commit comments