From 8bd3e61b2fbae618fc984e969b0d7f9978b8dcba Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 12 Dec 2024 08:43:32 +0100 Subject: [PATCH 1/3] Enhanced @deprecated phpdoc tag usage (#1398) --- src/contracts/UniversalDiscovery/Provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/UniversalDiscovery/Provider.php b/src/contracts/UniversalDiscovery/Provider.php index ffda858980..f0582c6dc2 100644 --- a/src/contracts/UniversalDiscovery/Provider.php +++ b/src/contracts/UniversalDiscovery/Provider.php @@ -64,7 +64,7 @@ public function getLocationGridViewData( public function getLocations(array $locationIds): array; /** - * @deprecated 4.6.0 The "\Ibexa\Contracts\AdminUi\UniversalDiscoveryProvider::getRestFormat()" method is deprecated, will be removed in 5.0. + * @deprecated 4.6.0 Will be removed in 5.0. */ public function getRestFormat($valueObject): array; From 8defa2510952a545211bfe5c8b3011ade18f8c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Thu, 12 Dec 2024 08:53:49 +0100 Subject: [PATCH 2/3] =?UTF-8?q?IBX-8937:=20Problem=20displaying=20the=20?= =?UTF-8?q?=E2=80=9CEmbed=E2=80=9D=20icon=20in=20text=20editor=20(#1400)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bundle/Resources/public/img/ibexa-icons.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ - + From 06d1b32b04eff7874884529ac3e43f5170ac4a7e Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Thu, 12 Dec 2024 14:24:20 +0100 Subject: [PATCH 3/3] IBX-9289: `NodeFactory` optimization (#1405) * IBX-9289: Move translations resolved in `NodeFactory` to node's extended info * IBX-9289: Remove dependency on Content * IBX-9289: Update integration tests --- .../Content/ContentTreeController.php | 2 +- .../ValueObjectVisitor/ContentTree/Node.php | 2 -- .../ContentTree/NodeExtendedInfoVisitor.php | 17 ++++++++++++++ src/lib/REST/Value/ContentTree/Node.php | 17 +------------- .../Value/ContentTree/NodeExtendedInfo.php | 22 +++++++++++++++---- src/lib/UI/Module/ContentTree/NodeFactory.php | 11 ++-------- .../REST/Schemas/ContentTreeNode.json | 2 -- .../REST/Schemas/ContentTreeNode.xsd | 2 -- .../Schemas/ContentTreeNodeExtendedInfo.json | 18 +++++++++++++-- .../Schemas/ContentTreeNodeExtendedInfo.xsd | 7 ++++++ ...pe-identifier-folder-and-landing-page.json | 5 ----- ...entifier-folder-and-media-location-id.json | 2 -- ...ent-type-identifier-folder-or-subtree.json | 5 ----- ...ter-by-content-type-identifier-folder.json | 4 ---- .../filter/json/no-filter.json | 6 ----- .../ContentTreeNode/filter/xml/no-filter.xml | 6 ----- .../ContentTreeNodeExtendedInfo.json | 3 +++ .../Snapshots/ContentTreeNodeExtendedInfo.xml | 3 +++ .../REST/Snapshots/ContentTreeRoot.json | 2 -- 19 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/bundle/Controller/Content/ContentTreeController.php b/src/bundle/Controller/Content/ContentTreeController.php index 372f914de5..92ad117f4f 100644 --- a/src/bundle/Controller/Content/ContentTreeController.php +++ b/src/bundle/Controller/Content/ContentTreeController.php @@ -194,7 +194,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/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php b/src/lib/REST/Output/ValueObjectVisitor/ContentTree/Node.php index f8d18f0bbb..fcee9b66da 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 9aa1755652..8e172614f9 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 73c2a11fc9..1c00d55c29 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",