diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 83fa832586..57cd9cbaa4 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -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; @@ -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, @@ -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 */