Skip to content

Commit

Permalink
TASK: Remove unnecessary childnodefilter in ui flowqueries
Browse files Browse the repository at this point in the history
The UI filters itself, so the two children queries with
different nodetypefilters have no effect on the final
outcome and are just slowing down the response.
  • Loading branch information
Sebobo committed Jul 4, 2024
1 parent 1de53f6 commit 287e6d5
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function renderNode(NodeInterface $node, ControllerContext $controllerCon
/**
* @param NodeInterface $node
* @param ControllerContext|null $controllerContext
* @param string $nodeTypeFilterOverride
* @param string|null $nodeTypeFilterOverride
* @return array|null
*/
public function renderNodeWithMinimalPropertiesAndChildrenInformation(NodeInterface $node, ControllerContext $controllerContext = null, string $nodeTypeFilterOverride = null)
Expand All @@ -137,15 +137,9 @@ public function renderNodeWithMinimalPropertiesAndChildrenInformation(NodeInterf

if ($controllerContext !== null) {
$nodeInfo = array_merge($nodeInfo, $this->getUriInformation($node, $controllerContext));
if ($controllerContext->getRequest()->hasArgument('presetBaseNodeType')) {
$presetBaseNodeType = $controllerContext->getRequest()->getArgument('presetBaseNodeType');
}
}

$baseNodeType = $nodeTypeFilterOverride ? $nodeTypeFilterOverride : (isset($presetBaseNodeType) ? $presetBaseNodeType : $this->defaultBaseNodeType);
$nodeTypeFilter = $this->buildNodeTypeFilterString($this->nodeTypeStringsToList($baseNodeType), $this->nodeTypeStringsToList($this->ignoredNodeTypeRole));

$nodeInfo['children'] = $this->renderChildrenInformation($node, $nodeTypeFilter);
$nodeInfo['children'] = $this->renderChildrenInformation($node);

$this->userLocaleService->switchToUILocale(true);

Expand All @@ -172,13 +166,9 @@ public function renderNodeWithPropertiesAndChildrenInformation(NodeInterface $no

if ($controllerContext !== null) {
$nodeInfo = array_merge($nodeInfo, $this->getUriInformation($node, $controllerContext));
if ($controllerContext->getRequest()->hasArgument('presetBaseNodeType')) {
$presetBaseNodeType = $controllerContext->getRequest()->getArgument('presetBaseNodeType');
}
}

$baseNodeType = $nodeTypeFilterOverride ?: (isset($presetBaseNodeType) ? $presetBaseNodeType : $this->defaultBaseNodeType);
$nodeInfo['children'] = $this->renderChildrenInformation($node, $baseNodeType);
$nodeInfo['children'] = $this->renderChildrenInformation($node);

$this->userLocaleService->switchToUILocale(true);

Expand Down Expand Up @@ -234,26 +224,17 @@ protected function getBasicNodeInformation(NodeInterface $node): array

/**
* Get information for all children of the given parent node.
*
* @param NodeInterface $node
* @param string $nodeTypeFilterString
* @return array
*/
protected function renderChildrenInformation(NodeInterface $node, string $nodeTypeFilterString): array
protected function renderChildrenInformation(NodeInterface $node): array
{
$documentChildNodes = $node->getChildNodes($nodeTypeFilterString);
// child nodes for content tree, must not include those nodes filtered out by `baseNodeType`
$contentChildNodes = $node->getChildNodes($this->buildContentChildNodeFilterString());
$childNodes = array_merge($documentChildNodes, $contentChildNodes);
$childNodes = $node->getChildNodes($this->buildNodeTypeFilterString([], [$this->ignoredNodeTypeRole]));

$mapper = static function (NodeInterface $childNode) {
return array_map(static function (NodeInterface $childNode) {
return [
'contextPath' => $childNode->getContextPath(),
'nodeType' => $childNode->getNodeType()->getName()
'nodeType' => $childNode->getNodeType()->getName(),
];
};

return array_map($mapper, $childNodes);
}, $childNodes);
}

/**
Expand Down

0 comments on commit 287e6d5

Please sign in to comment.