From 99a8ce135131969dfbe76ac862dbeec81209763e Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Mon, 24 Nov 2025 09:29:07 +0100 Subject: [PATCH] IBX-10602: Refactored `NodeFactory` to fetch translations for n first items --- src/lib/UI/Module/ContentTree/NodeFactory.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 0efb0ff38a..04a9495af3 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -116,6 +116,9 @@ public function createNode( $bookmarkedLocations, $requestFilter ); + + //TODO decide on the limit of version infos to load at once + $uninitializedContentInfoList = array_splice($uninitializedContentInfoList, 0, 30); $versionInfoById = $this->contentService->loadVersionInfoListByContentInfo($uninitializedContentInfoList); $aggregatedChildrenCount = null; @@ -123,7 +126,7 @@ public function createNode( $aggregatedChildrenCount = $this->countAggregatedSubitems($containerLocations, $requestFilter); } - $this->supplyTranslatedContentName($node, $versionInfoById); + $this->supplyContentName($node, $versionInfoById); $this->supplyChildrenCount($node, $aggregatedChildrenCount, $requestFilter); return $node; @@ -392,7 +395,7 @@ private function buildNode( $location->getId(), $location->getContentId(), $contentInfo->currentVersionNo, - '', // node name will be provided later by `supplyTranslatedContentName` method + $contentInfo->getName(), null !== $contentType ? $contentType->getIdentifier() : '', null === $contentType || $contentType->isContainer(), $location->isInvisible(), @@ -420,14 +423,16 @@ static function (Repository $repository) use ($contentInfo): int { /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo[] $versionInfoById */ - private function supplyTranslatedContentName(Node $node, array $versionInfoById): void + private function supplyContentName(Node $node, array $versionInfoById): void { if ($node->contentId !== self::TOP_NODE_CONTENT_ID) { - $node->name = $this->translationHelper->getTranslatedContentNameByVersionInfo($versionInfoById[$node->contentId]); + if (isset($versionInfoById[$node->contentId])) { + $node->name = $this->translationHelper->getTranslatedContentNameByVersionInfo($versionInfoById[$node->contentId]); + } } foreach ($node->children as $child) { - $this->supplyTranslatedContentName($child, $versionInfoById); + $this->supplyContentName($child, $versionInfoById); } }