Skip to content

Commit

Permalink
IBX-6017: Adapted solution to use loadVersionInfoListByContentInfo
Browse files Browse the repository at this point in the history
…method
  • Loading branch information
barw4 committed Jun 29, 2023
1 parent f67c5b3 commit b310a86
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/lib/UI/Module/ContentTree/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ public function createNode(
$sortClause,
$sortOrder
);
$versionInfoById = $this->contentService->loadVersionInfoListByContentInfo($uninitializedContentInfoList);

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


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

return $node;
Expand Down Expand Up @@ -345,7 +348,7 @@ private function buildNode(
$depth,
$location->id,
$location->contentId,
$contentInfo->name,
'', // node name will be provided later by `supplyTranslatedContentName` method
$contentType ? $contentType->identifier : '',
$contentType ? $contentType->isContainer : true,
$location->invisible || $location->hidden,
Expand All @@ -355,6 +358,20 @@ private function buildNode(
);
}

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

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

/**
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
Expand Down

0 comments on commit b310a86

Please sign in to comment.