@@ -89,7 +89,8 @@ class NodeInfoHelper implements ProtectedContextAwareInterface
89
89
public function renderNodeWithMinimalPropertiesAndChildrenInformation (
90
90
Node $ node ,
91
91
?ActionRequest $ actionRequest = null ,
92
- ?string $ nodeTypeFilterOverride = null
92
+ ?string $ nodeTypeFilterOverride = null ,
93
+ bool $ includeContentChildNodes = false
93
94
): ?array {
94
95
/** @todo implement custom node policy service
95
96
if (!$this->nodePolicyService->isNodeTreePrivilegeGranted($node)) {
@@ -119,7 +120,7 @@ public function renderNodeWithMinimalPropertiesAndChildrenInformation(
119
120
$ this ->nodeTypeStringsToList ($ this ->ignoredNodeTypeRole )
120
121
);
121
122
122
- $ nodeInfo ['children ' ] = $ this ->renderChildrenInformation ($ node , $ nodeTypeFilter );
123
+ $ nodeInfo ['children ' ] = $ this ->renderChildrenInformation ($ node , $ nodeTypeFilter, $ includeContentChildNodes );
123
124
124
125
$ this ->userLocaleService ->switchToUILocale (true );
125
126
@@ -215,27 +216,30 @@ protected function getBasicNodeInformation(Node $node): array
215
216
* @param string $nodeTypeFilterString
216
217
* @return array<int,array<string,string>>
217
218
*/
218
- protected function renderChildrenInformation (Node $ node , string $ nodeTypeFilterString ): array
219
+ protected function renderChildrenInformation (Node $ node , string $ nodeTypeFilterString, bool $ includeContentChildNodes = true ): array
219
220
{
220
- $ contentRepository = $ this ->contentRepositoryRegistry ->get ($ node ->contentRepositoryId );
221
221
$ subgraph = $ this ->contentRepositoryRegistry ->subgraphForNode ($ node );
222
222
223
223
$ documentChildNodes = $ subgraph ->findChildNodes (
224
224
$ node ->aggregateId ,
225
225
FindChildNodesFilter::create (nodeTypes: $ nodeTypeFilterString )
226
226
);
227
- // child nodes for content tree, must not include those nodes filtered out by `baseNodeType`
228
- $ contentChildNodes = $ subgraph ->findChildNodes (
229
- $ node ->aggregateId ,
230
- FindChildNodesFilter::create (
231
- nodeTypes: $ this ->buildContentChildNodeFilterString ()
232
- )
233
- );
234
- $ childNodes = $ documentChildNodes ->merge ($ contentChildNodes );
227
+
228
+ if ($ includeContentChildNodes ) {
229
+ // child nodes for content tree, must not include those nodes filtered out by `baseNodeType`
230
+ $ contentChildNodes = $ subgraph ->findChildNodes (
231
+ $ node ->aggregateId ,
232
+ FindChildNodesFilter::create (
233
+ nodeTypes: $ this ->buildContentChildNodeFilterString ()
234
+ )
235
+ );
236
+ $ childNodes = $ documentChildNodes ->merge ($ contentChildNodes );
237
+ } else {
238
+ $ childNodes = $ documentChildNodes ;
239
+ }
235
240
236
241
$ infos = [];
237
242
foreach ($ childNodes as $ childNode ) {
238
- $ contentRepository = $ this ->contentRepositoryRegistry ->get ($ childNode ->contentRepositoryId );
239
243
$ infos [] = [
240
244
'contextPath ' => NodeAddress::fromNode ($ childNode )->toJson (),
241
245
'nodeType ' => $ childNode ->nodeTypeName ->value
@@ -251,11 +255,12 @@ protected function renderChildrenInformation(Node $node, string $nodeTypeFilterS
251
255
public function renderNodes (
252
256
array $ nodes ,
253
257
ActionRequest $ actionRequest ,
254
- bool $ omitMostPropertiesForTreeState = false
258
+ bool $ omitMostPropertiesForTreeState = false ,
259
+ bool $ includeContentChildNodes = true
255
260
): array {
256
- $ mapper = function (Node $ node ) use ($ actionRequest , $ omitMostPropertiesForTreeState ) {
261
+ $ mapper = function (Node $ node ) use ($ actionRequest , $ omitMostPropertiesForTreeState, $ includeContentChildNodes ) {
257
262
return $ omitMostPropertiesForTreeState
258
- ? $ this ->renderNodeWithMinimalPropertiesAndChildrenInformation ($ node , $ actionRequest )
263
+ ? $ this ->renderNodeWithMinimalPropertiesAndChildrenInformation ($ node , $ actionRequest, includeContentChildNodes: $ includeContentChildNodes )
259
264
: $ this ->renderNodeWithPropertiesAndChildrenInformation ($ node , $ actionRequest );
260
265
};
261
266
return array_values (array_filter (array_map ($ mapper , $ nodes )));
@@ -265,7 +270,7 @@ public function renderNodes(
265
270
* @param array<int,?array<string,mixed>> $nodes
266
271
* @return array<int,?array<string,mixed>>
267
272
*/
268
- public function renderNodesWithParents (array $ nodes , ActionRequest $ actionRequest , ?string $ nodeTypeFilter = null ): array
273
+ public function renderNodesWithParents (array $ nodes , ActionRequest $ actionRequest , ?string $ nodeTypeFilter = null , bool $ includeContentChildNodes = true ): array
269
274
{
270
275
// For search operation we want to include all nodes, not respecting the "baseNodeType" setting
271
276
$ baseNodeTypeOverride = $ this ->documentNodeTypeRole ;
@@ -280,7 +285,8 @@ public function renderNodesWithParents(array $nodes, ActionRequest $actionReques
280
285
} elseif ($ renderedNode = $ this ->renderNodeWithMinimalPropertiesAndChildrenInformation (
281
286
$ node ,
282
287
$ actionRequest ,
283
- $ nodeTypeFilter ?? $ baseNodeTypeOverride
288
+ $ nodeTypeFilter ?? $ baseNodeTypeOverride ,
289
+ $ includeContentChildNodes
284
290
)) {
285
291
$ renderedNode ['matched ' ] = true ;
286
292
$ renderedNodes [$ node ->aggregateId ->value ] = $ renderedNode ;
@@ -302,7 +308,8 @@ public function renderNodesWithParents(array $nodes, ActionRequest $actionReques
302
308
$ renderedParentNode = $ this ->renderNodeWithMinimalPropertiesAndChildrenInformation (
303
309
$ parentNode ,
304
310
$ actionRequest ,
305
- $ baseNodeTypeOverride
311
+ $ baseNodeTypeOverride ,
312
+ $ includeContentChildNodes
306
313
);
307
314
if ($ renderedParentNode ) {
308
315
$ renderedParentNode ['intermediate ' ] = true ;
0 commit comments