diff --git a/src/bundle/Controller/Content/ContentTreeController.php b/src/bundle/Controller/Content/ContentTreeController.php index 50142ab94b..b3f9b0d33e 100644 --- a/src/bundle/Controller/Content/ContentTreeController.php +++ b/src/bundle/Controller/Content/ContentTreeController.php @@ -193,7 +193,7 @@ public function loadNodeExtendedInfoAction(Location $location): NodeExtendedInfo fn (string $languageCode): bool => $this->isPreviewable($location, $content, $languageCode) ); - return new NodeExtendedInfo($locationPermissionRestrictions, $previewableTranslations); + return new NodeExtendedInfo($locationPermissionRestrictions, $previewableTranslations, $translations); } /** diff --git a/src/bundle/Resources/public/img/ibexa-icons.svg b/src/bundle/Resources/public/img/ibexa-icons.svg index a6c1a53c6a..e0293dff56 100644 --- a/src/bundle/Resources/public/img/ibexa-icons.svg +++ b/src/bundle/Resources/public/img/ibexa-icons.svg @@ -374,7 +374,7 @@ - + diff --git a/src/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php b/src/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php index ccc6dfbed9..6c37466244 100644 --- a/src/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php +++ b/src/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php @@ -39,8 +39,6 @@ public function visit(Visitor $visitor, Generator $generator, $data) $generator->valueElement('versionNo', $data->versionNo); - $generator->valueElement('translations', implode(',', $data->translations)); - $generator->valueElement('mainLanguageCode', $data->mainLanguageCode); $generator->startValueElement('name', $data->name); diff --git a/src/lib/REST/Output/ValueObjectVisitor/ContentTree/NodeExtendedInfoVisitor.php b/src/lib/REST/Output/ValueObjectVisitor/ContentTree/NodeExtendedInfoVisitor.php index 3d073f88d7..c080b4a631 100644 --- a/src/lib/REST/Output/ValueObjectVisitor/ContentTree/NodeExtendedInfoVisitor.php +++ b/src/lib/REST/Output/ValueObjectVisitor/ContentTree/NodeExtendedInfoVisitor.php @@ -31,6 +31,7 @@ public function visit(Visitor $visitor, Generator $generator, $data): void $this->buildPermissionNode($data->getPermissionRestrictions(), $generator); $this->buildPreviewableTranslationsNode($data->getPreviewableTranslations(), $generator); + $this->buildTranslationsNode($data->getTranslations(), $generator); $generator->endObjectElement(self::MAIN_ELEMENT); } @@ -51,6 +52,22 @@ protected function buildPreviewableTranslationsNode( $generator->endHashElement('previewableTranslations'); } + /** + * @param array $translations + */ + protected function buildTranslationsNode( + array $translations, + Generator $generator + ): void { + $generator->startHashElement('translations'); + $generator->startList('values'); + foreach ($translations as $value) { + $generator->valueElement('value', $value); + } + $generator->endList('values'); + $generator->endHashElement('translations'); + } + /** * @phpstan-param TPermissionRestrictions $permissionRestrictions */ diff --git a/src/lib/REST/Value/ContentTree/Node.php b/src/lib/REST/Value/ContentTree/Node.php index bd1c364ecc..d5b0312ce8 100644 --- a/src/lib/REST/Value/ContentTree/Node.php +++ b/src/lib/REST/Value/ContentTree/Node.php @@ -23,9 +23,6 @@ class Node extends RestValue public int $versionNo; - /** @var string[] */ - public array $translations; - /** @var string */ public $name; @@ -56,24 +53,13 @@ class Node extends RestValue public string $mainLanguageCode; /** - * @param int $depth - * @param int $locationId - * @param int $contentId - * @param string[] $translations - * @param string $name - * @param string $contentTypeIdentifier - * @param bool $isContainer - * @param bool $isInvisible - * @param int $displayLimit - * @param int $totalChildrenCount - * @param \Ibexa\AdminUi\REST\Value\ContentTree\Node[] $children + * @param array<\Ibexa\AdminUi\REST\Value\ContentTree\Node> $children */ public function __construct( int $depth, int $locationId, int $contentId, int $versionNo, - array $translations, string $name, string $contentTypeIdentifier, bool $isContainer, @@ -90,7 +76,6 @@ public function __construct( $this->locationId = $locationId; $this->contentId = $contentId; $this->versionNo = $versionNo; - $this->translations = $translations; $this->name = $name; $this->isInvisible = $isInvisible; $this->contentTypeIdentifier = $contentTypeIdentifier; diff --git a/src/lib/REST/Value/ContentTree/NodeExtendedInfo.php b/src/lib/REST/Value/ContentTree/NodeExtendedInfo.php index 7258507c65..f1079b66a4 100644 --- a/src/lib/REST/Value/ContentTree/NodeExtendedInfo.php +++ b/src/lib/REST/Value/ContentTree/NodeExtendedInfo.php @@ -28,20 +28,26 @@ final class NodeExtendedInfo extends RestValue /** @phpstan-var TPermissionRestrictions|null */ private ?array $permissions; - /** @var string[] */ + /** @var array */ private array $previewableTranslations; + /** @var array */ + private array $translations; + /** * @phpstan-param TPermissionRestrictions|null $permissions * - * @param string[] $previewableTranslation + * @param array $previewableTranslation + * @param array $translations */ public function __construct( ?array $permissions = null, - array $previewableTranslation = [] + array $previewableTranslation = [], + array $translations = [] ) { $this->permissions = $permissions; $this->previewableTranslations = $previewableTranslation; + $this->translations = $translations; } /** @@ -53,10 +59,18 @@ public function getPermissionRestrictions(): ?array } /** - * @return string[] + * @return array */ public function getPreviewableTranslations(): array { return $this->previewableTranslations; } + + /** + * @return array + */ + public function getTranslations(): array + { + return $this->translations; + } } diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 1169718f7a..314cb1da64 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -356,9 +356,6 @@ private function buildNode( $containerLocations[] = $location; } - $content = $location->getContent(); - $versionInfo = $content->getVersionInfo(); - $limit = $this->resolveLoadLimit($loadSubtreeRequestNode); $offset = null !== $loadSubtreeRequestNode ? $loadSubtreeRequestNode->offset @@ -391,15 +388,11 @@ private function buildNode( } } - $translations = $versionInfo->getLanguageCodes(); - $mainLanguageCode = $versionInfo->getContentInfo()->getMainLanguageCode(); - return new Node( $depth, $location->getId(), $location->getContentId(), - $versionInfo->getVersionNo(), - $translations, + $contentInfo->currentVersionNo, '', // node name will be provided later by `supplyTranslatedContentName` method null !== $contentType ? $contentType->getIdentifier() : '', null === $contentType || $contentType->isContainer(), @@ -408,7 +401,7 @@ private function buildNode( $totalChildrenCount, $this->getReverseRelationsCount($contentInfo), isset($bookmarkLocations[$location->getId()]), - $mainLanguageCode, + $contentInfo->getMainLanguageCode(), $children, $location->getPathString() ); diff --git a/tests/integration/Resources/REST/Schemas/ContentTreeNode.json b/tests/integration/Resources/REST/Schemas/ContentTreeNode.json index 8652632758..7c6c5c1537 100644 --- a/tests/integration/Resources/REST/Schemas/ContentTreeNode.json +++ b/tests/integration/Resources/REST/Schemas/ContentTreeNode.json @@ -88,7 +88,6 @@ "pathString", "contentId", "versionNo", - "translations", "name", "contentTypeIdentifier", "isContainer", @@ -109,7 +108,6 @@ "pathString", "contentId", "versionNo", - "translations", "name", "contentTypeIdentifier", "isContainer", diff --git a/tests/integration/Resources/REST/Schemas/ContentTreeNode.xsd b/tests/integration/Resources/REST/Schemas/ContentTreeNode.xsd index d3cd136b92..9da3d622eb 100644 --- a/tests/integration/Resources/REST/Schemas/ContentTreeNode.xsd +++ b/tests/integration/Resources/REST/Schemas/ContentTreeNode.xsd @@ -7,7 +7,6 @@ - @@ -24,7 +23,6 @@ - diff --git a/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.json b/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.json index 753b688a84..3d520aa1d9 100644 --- a/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.json +++ b/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.json @@ -66,12 +66,26 @@ ] } } - } + }, + "translations": { + "type": "object", + "properties": { + "values": { + "type": "array", + "items": [ + { + "type": "string" + } + ] + } + } + } }, "required": [ "_media-type", "permissions", - "previewableTranslations" + "previewableTranslations", + "translations" ] } }, diff --git a/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.xsd b/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.xsd index cd01c211ce..c9f6409121 100644 --- a/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.xsd +++ b/tests/integration/Resources/REST/Schemas/ContentTreeNodeExtendedInfo.xsd @@ -33,6 +33,13 @@ + + + + + + + diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-landing-page.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-landing-page.json index b93aa863fd..2125da70f2 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-landing-page.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-landing-page.json @@ -17,7 +17,6 @@ "pathString": "/1/2/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-GB", "versionNo": 1 }, { @@ -35,7 +34,6 @@ "pathString": "/1/43/", "reverseRelationsCount": 0, "totalChildrenCount": 3, - "translations": "eng-US", "versionNo": 1 }, { @@ -53,7 +51,6 @@ "pathString": "/1/48/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 }, { @@ -71,7 +68,6 @@ "pathString": "/1/58/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 } ], @@ -87,7 +83,6 @@ "pathString": "/1/", "reverseRelationsCount": 0, "totalChildrenCount": 4, - "translations": "", "versionNo": 1 } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-media-location-id.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-media-location-id.json index 8d133ecb73..a5c583fdd9 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-media-location-id.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-and-media-location-id.json @@ -17,7 +17,6 @@ "pathString": "/1/43/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 } ], @@ -33,7 +32,6 @@ "pathString": "/1/", "reverseRelationsCount": 0, "totalChildrenCount": 1, - "translations": "", "versionNo": 1 } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-or-subtree.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-or-subtree.json index 240568a68f..c93a0a1d7c 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-or-subtree.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder-or-subtree.json @@ -17,7 +17,6 @@ "pathString": "/1/43/", "reverseRelationsCount": 0, "totalChildrenCount": 3, - "translations": "eng-US", "versionNo": 1 }, { @@ -35,7 +34,6 @@ "pathString": "/1/48/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 }, { @@ -53,7 +51,6 @@ "pathString": "/1/5/", "reverseRelationsCount": 0, "totalChildrenCount": 5, - "translations": "eng-US", "versionNo": 1 }, { @@ -71,7 +68,6 @@ "pathString": "/1/58/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 } ], @@ -87,7 +83,6 @@ "pathString": "/1/", "reverseRelationsCount": 0, "totalChildrenCount": 4, - "translations": "", "versionNo": 1 } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder.json index ded51eb7fd..362e61fad0 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/filter-by-content-type-identifier-folder.json @@ -17,7 +17,6 @@ "pathString": "/1/43/", "reverseRelationsCount": 0, "totalChildrenCount": 3, - "translations": "eng-US", "versionNo": 1 }, { @@ -35,7 +34,6 @@ "pathString": "/1/48/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 }, { @@ -53,7 +51,6 @@ "pathString": "/1/58/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 } ], @@ -69,7 +66,6 @@ "pathString": "/1/", "reverseRelationsCount": 0, "totalChildrenCount": 3, - "translations": "", "versionNo": 1 } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/no-filter.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/no-filter.json index 0337e22d7e..0892041a5a 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/no-filter.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/json/no-filter.json @@ -17,7 +17,6 @@ "pathString": "/1/2/", "reverseRelationsCount": 0, "totalChildrenCount": 1, - "translations": "eng-GB", "versionNo": 1 }, { @@ -35,7 +34,6 @@ "pathString": "/1/43/", "reverseRelationsCount": 0, "totalChildrenCount": 3, - "translations": "eng-US", "versionNo": 1 }, { @@ -53,7 +51,6 @@ "pathString": "/1/48/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 }, { @@ -71,7 +68,6 @@ "pathString": "/1/5/", "reverseRelationsCount": 0, "totalChildrenCount": 5, - "translations": "eng-US", "versionNo": 1 }, { @@ -89,7 +85,6 @@ "pathString": "/1/58/", "reverseRelationsCount": 0, "totalChildrenCount": 0, - "translations": "eng-US", "versionNo": 1 } ], @@ -105,7 +100,6 @@ "pathString": "/1/", "reverseRelationsCount": 0, "totalChildrenCount": 5, - "translations": "", "versionNo": 1 } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/xml/no-filter.xml b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/xml/no-filter.xml index e4a55a1fc0..a28ef0d08a 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/xml/no-filter.xml +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNode/filter/xml/no-filter.xml @@ -4,7 +4,6 @@ /1/ 0 1 - eng-GB @@ -19,7 +18,6 @@ /1/2/ 57 1 - eng-GB eng-GB Home landing_page @@ -35,7 +33,6 @@ /1/43/ 41 1 - eng-US eng-US Media folder @@ -51,7 +48,6 @@ /1/48/ 45 1 - eng-US eng-US Setup folder @@ -67,7 +63,6 @@ /1/5/ 4 1 - eng-US eng-US Users user_group @@ -83,7 +78,6 @@ /1/58/ 56 1 - eng-US eng-US Design folder diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.json b/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.json index 85be359381..25a913466a 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.json @@ -38,6 +38,9 @@ ], "previewableTranslations": { "values": ["eng-GB"] + }, + "translations": { + "values": ["eng-GB"] } } } diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.xml b/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.xml index 926eeef47f..2fd90b0e52 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.xml +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeNodeExtendedInfo.xml @@ -26,4 +26,7 @@ eng-GB + + eng-GB + diff --git a/tests/integration/Resources/REST/Snapshots/ContentTreeRoot.json b/tests/integration/Resources/REST/Snapshots/ContentTreeRoot.json index 1a7c7c051d..aacf1ed1bd 100644 --- a/tests/integration/Resources/REST/Snapshots/ContentTreeRoot.json +++ b/tests/integration/Resources/REST/Snapshots/ContentTreeRoot.json @@ -8,7 +8,6 @@ "mainLanguageCode": "eng-GB", "contentId": 57, "versionNo": 1, - "translations": "eng-GB", "name": "Home", "pathString": "/1/2/", "contentTypeIdentifier": "landing_page", @@ -25,7 +24,6 @@ "mainLanguageCode": "eng-GB", "contentId": 58, "versionNo": 1, - "translations": "eng-GB", "name": "Contact Us", "pathString": "/1/2/60/", "contentTypeIdentifier": "feedback_form",