Skip to content

Commit

Permalink
IBX-6017: Avoid loading whole content in the Content Tree (#2104)
Browse files Browse the repository at this point in the history
* IBX-6017: Avoid loading whole content in the Content Tree

* IBX-6017: Adapted solution to use `loadVersionInfoListByContentInfo` method

* IBX-6017: CS
  • Loading branch information
barw4 authored Jul 31, 2023
1 parent 22cea7f commit 6a8d87c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/lib/UI/Module/ContentTree/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,24 @@ public function createNode(
): Node {
$uninitializedContentInfoList = [];
$containerLocations = [];
$node = $this->buildNode($location, $uninitializedContentInfoList, $containerLocations, $loadSubtreeRequestNode, $loadChildren, $depth, $sortClause, $sortOrder);
$contentById = $this->contentService->loadContentListByContentInfo($uninitializedContentInfoList);
$node = $this->buildNode(
$location,
$uninitializedContentInfoList,
$containerLocations,
$loadSubtreeRequestNode,
$loadChildren,
$depth,
$sortClause,
$sortOrder
);
$versionInfoById = $this->contentService->loadVersionInfoListByContentInfo($uninitializedContentInfoList);

$aggregatedChildrenCount = null;
if ($this->searchService->supports(SearchService::CAPABILITY_AGGREGATIONS)) {
$aggregatedChildrenCount = $this->countAggregatedSubitems($containerLocations);
}

$this->supplyTranslatedContentName($node, $contentById);
$this->supplyTranslatedContentName($node, $versionInfoById);
$this->supplyChildrenCount($node, $aggregatedChildrenCount);

return $node;
Expand Down Expand Up @@ -349,16 +358,16 @@ private function buildNode(
}

/**
* @param \eZ\Publish\API\Repository\Values\Content\Content[] $contentById
* @param \eZ\Publish\API\Repository\Values\Content\VersionInfo[] $versionInfoById
*/
private function supplyTranslatedContentName(Node $node, array $contentById): void
private function supplyTranslatedContentName(Node $node, array $versionInfoById): void
{
if ($node->contentId !== self::TOP_NODE_CONTENT_ID) {
$node->name = $this->translationHelper->getTranslatedContentName($contentById[$node->contentId]);
$node->name = $this->translationHelper->getTranslatedContentNameByVersionInfo($versionInfoById[$node->contentId]);
}

foreach ($node->children as $child) {
$this->supplyTranslatedContentName($child, $contentById);
$this->supplyTranslatedContentName($child, $versionInfoById);
}
}

Expand Down

0 comments on commit 6a8d87c

Please # to comment.