From 0c48fff02fcc8d4380a6e39f25dd1a46df7d016c Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Fri, 2 Jul 2021 11:48:25 +0200 Subject: [PATCH 01/10] Added aggregation support to NodeFactory --- src/lib/UI/Module/ContentTree/NodeFactory.php | 119 ++++++++++++++++-- 1 file changed, 107 insertions(+), 12 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 9332f528b5..4f4fc94288 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -16,6 +16,7 @@ use eZ\Publish\API\Repository\Values\Content\Query; use eZ\Publish\API\Repository\Values\Content\Query\Criterion; use eZ\Publish\API\Repository\Values\Content\Query\SortClause; +use eZ\Publish\API\Repository\Values\Content\Search\AggregationResult\TermAggregationResult; use eZ\Publish\API\Repository\Values\Content\Search\SearchResult; use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; use eZ\Publish\Core\Helper\TranslationHelper; @@ -33,6 +34,7 @@ final class NodeFactory 'DatePublished' => SortClause\DatePublished::class, 'ContentName' => SortClause\ContentName::class, ]; + private const MAX_AGGREGATED_LOCATION_IDS = 100; /** @var \eZ\Publish\API\Repository\ContentService */ private $contentService; @@ -46,6 +48,9 @@ final class NodeFactory /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ private $configResolver; + /** @var array */ + private $containerLocations; + public function __construct( ContentService $contentService, SearchService $searchService, @@ -72,9 +77,17 @@ public function createNode( string $sortOrder = Query::SORT_ASC ): Node { $uninitializedContentInfoList = []; - $node = $this->buildNode($location, $uninitializedContentInfoList, $loadSubtreeRequestNode, $loadChildren, $depth, $sortClause, $sortOrder); + $containerLocations = []; + $node = $this->buildNode($location, $uninitializedContentInfoList, $containerLocations, $loadSubtreeRequestNode, $loadChildren, $depth, $sortClause, $sortOrder); $contentById = $this->contentService->loadContentListByContentInfo($uninitializedContentInfoList); + + $aggregatedChildrenCount = null; + if ($this->searchService->supports(SearchService::CAPABILITY_AGGREGATIONS)) { + $aggregatedChildrenCount = $this->countAggregatedSubitems($containerLocations); + } + $this->supplyTranslatedContentName($node, $contentById); + $this->supplyChildrenCount($node, $aggregatedChildrenCount); return $node; } @@ -106,7 +119,7 @@ private function findSubitems( ?string $sortClause = null, string $sortOrder = Query::SORT_ASC ): SearchResult { - $searchQuery = $this->getSearchQuery($parentLocation); + $searchQuery = $this->getSearchQuery($parentLocation->id); $searchQuery->limit = $limit; $searchQuery->offset = $offset; @@ -120,10 +133,10 @@ private function findSubitems( * * @return \eZ\Publish\API\Repository\Values\Content\LocationQuery */ - private function getSearchQuery(Location $parentLocation): LocationQuery + private function getSearchQuery(int $parentLocationId): LocationQuery { $searchQuery = new LocationQuery(); - $searchQuery->filter = new Criterion\ParentLocationId($parentLocation->id); + $searchQuery->filter = new Criterion\ParentLocationId($parentLocationId); $contentTypeCriterion = null; @@ -162,15 +175,15 @@ private function findChild(int $locationId, LoadSubtreeRequestNode $loadSubtreeR } /** - * @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation + * @param int $parentLocationId * * @return int * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException */ - private function countSubitems(Location $parentLocation): int + private function countSubitems(int $parentLocationId): int { - $searchQuery = $this->getSearchQuery($parentLocation); + $searchQuery = $this->getSearchQuery($parentLocationId); $searchQuery->limit = 0; $searchQuery->offset = 0; @@ -179,6 +192,62 @@ private function countSubitems(Location $parentLocation): int return $this->searchService->findLocations($searchQuery)->totalCount; } + /** + * @param \eZ\Publish\API\Repository\Values\Content\Location[] $containerLocations + * + * @return array + */ + private function countAggregatedSubitems(array $containerLocations): array + { + if (empty($containerLocations)) { + return []; + } + + if (count($containerLocations) > self::MAX_AGGREGATED_LOCATION_IDS) { + $containerLocationsChunks = array_chunk($containerLocations, self::MAX_AGGREGATED_LOCATION_IDS); + + $result = []; + foreach ($containerLocationsChunks as $containerLocationsChunk) { + $result = array_replace($result, $this->countAggregatedSubitems($containerLocationsChunk)); + } + + return $result; + } + + $parentLocationIds = []; + foreach ($containerLocations as $containerLocation) { + $parentLocationIds[] = $containerLocation->id; + } + + $searchQuery = new LocationQuery(); + $searchQuery->filter = new Criterion\ParentLocationId($parentLocationIds); + $searchQuery->aggregations[] = new Query\Aggregation\RawTermAggregation('childrens', 'parent_id_id'); + $searchQuery->aggregations[0]->setLimit(count($parentLocationIds)); + $result = $this->searchService->findLocations($searchQuery); + + try { + return $this->aggregationResultToArray($result->aggregations->get('childrens')); + } catch (\eZ\Publish\API\Repository\Exceptions\OutOfBoundsException $e) { + } + + return []; + } + + /** + * @param TermAggregationResult $aggregationResult + * + * @return array + */ + private function aggregationResultToArray(TermAggregationResult $aggregationResult): array + { + $resultsAsArray = []; + foreach ($aggregationResult->getEntries() as $entry) { + $resultsAsArray[$entry->getKey()] = $entry->getCount(); + } + + return $resultsAsArray; + } + private function getSetting(string $name) { return $this->configResolver->getParameter("content_tree_module.$name"); @@ -233,6 +302,7 @@ private function getSortClauses( private function buildNode( Location $location, array &$uninitializedContentInfoList, + array &$containerLocations, ?LoadSubtreeRequestNode $loadSubtreeRequestNode = null, bool $loadChildren = false, int $depth = 0, @@ -250,11 +320,16 @@ private function buildNode( ? $contentInfo->getContentType() : null; + if ($contentType && $contentType->isContainer) { + $containerLocations[] = $location; + } + $limit = $this->resolveLoadLimit($loadSubtreeRequestNode); $offset = null !== $loadSubtreeRequestNode ? $loadSubtreeRequestNode->offset : 0; + $totalChildrenCount = 0; $children = []; if ($loadChildren && $depth < $this->getSetting('tree_max_depth')) { $searchResult = $this->findSubitems($location, $limit, $offset, $sortClause, $sortOrder); @@ -269,6 +344,7 @@ private function buildNode( $children[] = $this->buildNode( $childLocation, $uninitializedContentInfoList, + $containerLocations, $childLoadSubtreeRequestNode, null !== $childLoadSubtreeRequestNode, $depth + 1, @@ -276,11 +352,6 @@ private function buildNode( Query::SORT_ASC ); } - } else { - $totalChildrenCount = 0; - if ($contentType && $contentType->isContainer) { - $totalChildrenCount = $this->countSubitems($location); - } } return new Node( @@ -310,4 +381,28 @@ private function supplyTranslatedContentName(Node $node, array $contentById): vo $this->supplyTranslatedContentName($child, $contentById); } } + + /** + * @param array|null $aggregationResult + * + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException + */ + private function supplyChildrenCount(Node $node, array $aggregationResult = null): void + { + if ($node->isContainer) { + if ($aggregationResult) { + $totalCount = isset($aggregationResult[$node->locationId]) ? + $aggregationResult[$node->locationId] : + 0; + } else { + $totalCount = $this->countSubitems($node->locationId); + } + + $node->totalChildrenCount = $totalCount; + } + + foreach ($node->children as $child) { + $this->supplyChildrenCount($child, $aggregationResult); + } + } } From eaaedde5d9d13e2e63345ab44e7c62c9cd8d9ac9 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Mon, 19 Jul 2021 11:20:58 +0200 Subject: [PATCH 02/10] Changed to use LocationChildrenTermAggregation --- src/lib/UI/Module/ContentTree/NodeFactory.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 4f4fc94288..de6ba0679d 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -221,7 +221,7 @@ private function countAggregatedSubitems(array $containerLocations): array $searchQuery = new LocationQuery(); $searchQuery->filter = new Criterion\ParentLocationId($parentLocationIds); - $searchQuery->aggregations[] = new Query\Aggregation\RawTermAggregation('childrens', 'parent_id_id'); + $searchQuery->aggregations[] = new Query\Aggregation\LocationChildrenTermAggregation('childrens'); $searchQuery->aggregations[0]->setLimit(count($parentLocationIds)); $result = $this->searchService->findLocations($searchQuery); @@ -242,7 +242,9 @@ private function aggregationResultToArray(TermAggregationResult $aggregationResu { $resultsAsArray = []; foreach ($aggregationResult->getEntries() as $entry) { - $resultsAsArray[$entry->getKey()] = $entry->getCount(); + /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ + $location = $entry->getKey(); + $resultsAsArray[$location->id] = $entry->getCount(); } return $resultsAsArray; From 9082b5c4fcc176b2c56378f64f2a182848f607ae Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Fri, 23 Jul 2021 12:36:10 +0200 Subject: [PATCH 03/10] LocationChildrenTermAggregation moved to different namespace in kernel --- src/lib/UI/Module/ContentTree/NodeFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index de6ba0679d..8fabe1beee 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -221,7 +221,7 @@ private function countAggregatedSubitems(array $containerLocations): array $searchQuery = new LocationQuery(); $searchQuery->filter = new Criterion\ParentLocationId($parentLocationIds); - $searchQuery->aggregations[] = new Query\Aggregation\LocationChildrenTermAggregation('childrens'); + $searchQuery->aggregations[] = new Query\Aggregation\Location\LocationChildrenTermAggregation('childrens'); $searchQuery->aggregations[0]->setLimit(count($parentLocationIds)); $result = $this->searchService->findLocations($searchQuery); From 50e062e342b6ee6dcd643e5418bb29089b819a43 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Mon, 26 Jul 2021 13:06:44 +0200 Subject: [PATCH 04/10] Changes after CR --- src/lib/UI/Module/ContentTree/NodeFactory.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 8fabe1beee..6f735c6289 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -10,6 +10,7 @@ use eZ\Publish\API\Repository\ContentService; use eZ\Publish\API\Repository\Exceptions\NotImplementedException; +use eZ\Publish\API\Repository\Exceptions\OutOfBoundsException; use eZ\Publish\API\Repository\SearchService; use eZ\Publish\API\Repository\Values\Content\Location; use eZ\Publish\API\Repository\Values\Content\LocationQuery; @@ -24,6 +25,7 @@ use EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode; use EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\Node; + /** * @internal */ @@ -48,9 +50,6 @@ final class NodeFactory /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ private $configResolver; - /** @var array */ - private $containerLocations; - public function __construct( ContentService $contentService, SearchService $searchService, @@ -214,27 +213,26 @@ private function countAggregatedSubitems(array $containerLocations): array return $result; } - $parentLocationIds = []; - foreach ($containerLocations as $containerLocation) { - $parentLocationIds[] = $containerLocation->id; - } + $parentLocationIds = array_column($containerLocations, 'id'); $searchQuery = new LocationQuery(); $searchQuery->filter = new Criterion\ParentLocationId($parentLocationIds); - $searchQuery->aggregations[] = new Query\Aggregation\Location\LocationChildrenTermAggregation('childrens'); - $searchQuery->aggregations[0]->setLimit(count($parentLocationIds)); + $locationChildrenTermAggregation = new Query\Aggregation\Location\LocationChildrenTermAggregation('childrens'); + $locationChildrenTermAggregation->setLimit(count($parentLocationIds)); + $searchQuery->aggregations[] = $locationChildrenTermAggregation; + $result = $this->searchService->findLocations($searchQuery); try { return $this->aggregationResultToArray($result->aggregations->get('childrens')); - } catch (\eZ\Publish\API\Repository\Exceptions\OutOfBoundsException $e) { + } catch (OutOfBoundsException $e) { } return []; } /** - * @param TermAggregationResult $aggregationResult + * @param \eZ\Publish\API\Repository\Values\Content\Search\AggregationResult\TermAggregationResult $aggregationResult * * @return array */ From 2f7164f20fa9b5ff48c24fd6d48b259b2384ba22 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Mon, 26 Jul 2021 13:09:57 +0200 Subject: [PATCH 05/10] CS Fix --- src/lib/UI/Module/ContentTree/NodeFactory.php | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 6f735c6289..f2e38430cb 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -25,7 +25,6 @@ use EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode; use EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\Node; - /** * @internal */ @@ -91,11 +90,6 @@ public function createNode( return $node; } - /** - * @param \EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode|null $loadSubtreeRequestNode - * - * @return int - */ private function resolveLoadLimit(?LoadSubtreeRequestNode $loadSubtreeRequestNode): int { $limit = $this->getSetting('load_more_limit'); @@ -129,8 +123,6 @@ private function findSubitems( /** * @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation - * - * @return \eZ\Publish\API\Repository\Values\Content\LocationQuery */ private function getSearchQuery(int $parentLocationId): LocationQuery { @@ -156,12 +148,6 @@ private function getSearchQuery(int $parentLocationId): LocationQuery return $searchQuery; } - /** - * @param int $locationId - * @param \EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode $loadSubtreeRequestNode - * - * @return \EzSystems\EzPlatformAdminUi\REST\Value\ContentTree\LoadSubtreeRequestNode|null - */ private function findChild(int $locationId, LoadSubtreeRequestNode $loadSubtreeRequestNode): ?LoadSubtreeRequestNode { foreach ($loadSubtreeRequestNode->children as $child) { @@ -174,10 +160,6 @@ private function findChild(int $locationId, LoadSubtreeRequestNode $loadSubtreeR } /** - * @param int $parentLocationId - * - * @return int - * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException */ private function countSubitems(int $parentLocationId): int @@ -193,8 +175,6 @@ private function countSubitems(int $parentLocationId): int /** * @param \eZ\Publish\API\Repository\Values\Content\Location[] $containerLocations - * - * @return array */ private function countAggregatedSubitems(array $containerLocations): array { @@ -202,7 +182,7 @@ private function countAggregatedSubitems(array $containerLocations): array return []; } - if (count($containerLocations) > self::MAX_AGGREGATED_LOCATION_IDS) { + if (\count($containerLocations) > self::MAX_AGGREGATED_LOCATION_IDS) { $containerLocationsChunks = array_chunk($containerLocations, self::MAX_AGGREGATED_LOCATION_IDS); $result = []; @@ -218,7 +198,7 @@ private function countAggregatedSubitems(array $containerLocations): array $searchQuery = new LocationQuery(); $searchQuery->filter = new Criterion\ParentLocationId($parentLocationIds); $locationChildrenTermAggregation = new Query\Aggregation\Location\LocationChildrenTermAggregation('childrens'); - $locationChildrenTermAggregation->setLimit(count($parentLocationIds)); + $locationChildrenTermAggregation->setLimit(\count($parentLocationIds)); $searchQuery->aggregations[] = $locationChildrenTermAggregation; $result = $this->searchService->findLocations($searchQuery); @@ -231,11 +211,6 @@ private function countAggregatedSubitems(array $containerLocations): array return []; } - /** - * @param \eZ\Publish\API\Repository\Values\Content\Search\AggregationResult\TermAggregationResult $aggregationResult - * - * @return array - */ private function aggregationResultToArray(TermAggregationResult $aggregationResult): array { $resultsAsArray = []; @@ -383,8 +358,6 @@ private function supplyTranslatedContentName(Node $node, array $contentById): vo } /** - * @param array|null $aggregationResult - * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException */ private function supplyChildrenCount(Node $node, array $aggregationResult = null): void From b99d24d09a83624611f540011bb91db7a6320763 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 29 Jul 2021 14:49:31 +0200 Subject: [PATCH 06/10] Changes after CR#3 --- .../Resources/config/default_parameters.yaml | 1 + .../config/services/modules/content_tree.yaml | 1 + src/lib/UI/Module/ContentTree/NodeFactory.php | 21 ++++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/bundle/Resources/config/default_parameters.yaml b/src/bundle/Resources/config/default_parameters.yaml index 3a500a1253..a0c8c715ab 100644 --- a/src/bundle/Resources/config/default_parameters.yaml +++ b/src/bundle/Resources/config/default_parameters.yaml @@ -75,3 +75,4 @@ parameters: ez_systems.multifile_upload.max_file_size: 5242880 + ezplatform.nodefactory.max_location_ids_in_single_aggregation: 100 diff --git a/src/bundle/Resources/config/services/modules/content_tree.yaml b/src/bundle/Resources/config/services/modules/content_tree.yaml index 486fd0f429..1352fb4ee7 100644 --- a/src/bundle/Resources/config/services/modules/content_tree.yaml +++ b/src/bundle/Resources/config/services/modules/content_tree.yaml @@ -9,6 +9,7 @@ services: $contentService: '@ezpublish.api.service.content' $translationHelper: '@ezpublish.translation_helper' $configResolver: '@ezpublish.config.resolver' + $maxLocationIdsInSingleAggregation: '%ezplatform.nodefactory.max_location_ids_in_single_aggregation%' EzSystems\EzPlatformAdminUi\UI\Config\Provider\Module\ContentTree: tags: diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index f2e38430cb..15a459d33e 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -35,7 +35,6 @@ final class NodeFactory 'DatePublished' => SortClause\DatePublished::class, 'ContentName' => SortClause\ContentName::class, ]; - private const MAX_AGGREGATED_LOCATION_IDS = 100; /** @var \eZ\Publish\API\Repository\ContentService */ private $contentService; @@ -49,16 +48,21 @@ final class NodeFactory /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ private $configResolver; + /** @var int */ + private $maxLocationIdsInSingleAggregation; + public function __construct( ContentService $contentService, SearchService $searchService, TranslationHelper $translationHelper, - ConfigResolverInterface $configResolver + ConfigResolverInterface $configResolver, + int $maxLocationIdsInSingleAggregation ) { $this->contentService = $contentService; $this->searchService = $searchService; $this->translationHelper = $translationHelper; $this->configResolver = $configResolver; + $this->maxLocationIdsInSingleAggregation = $maxLocationIdsInSingleAggregation; } /** @@ -182,8 +186,8 @@ private function countAggregatedSubitems(array $containerLocations): array return []; } - if (\count($containerLocations) > self::MAX_AGGREGATED_LOCATION_IDS) { - $containerLocationsChunks = array_chunk($containerLocations, self::MAX_AGGREGATED_LOCATION_IDS); + if (\count($containerLocations) > $this->maxLocationIdsInSingleAggregation) { + $containerLocationsChunks = array_chunk($containerLocations, $this->maxLocationIdsInSingleAggregation); $result = []; foreach ($containerLocationsChunks as $containerLocationsChunk) { @@ -203,9 +207,8 @@ private function countAggregatedSubitems(array $containerLocations): array $result = $this->searchService->findLocations($searchQuery); - try { + if ($result->aggregations->has('childrens')) { return $this->aggregationResultToArray($result->aggregations->get('childrens')); - } catch (OutOfBoundsException $e) { } return []; @@ -295,7 +298,7 @@ private function buildNode( ? $contentInfo->getContentType() : null; - if ($contentType && $contentType->isContainer) { + if ($contentType !== null && $contentType->isContainer) { $containerLocations[] = $location; } @@ -364,9 +367,7 @@ private function supplyChildrenCount(Node $node, array $aggregationResult = null { if ($node->isContainer) { if ($aggregationResult) { - $totalCount = isset($aggregationResult[$node->locationId]) ? - $aggregationResult[$node->locationId] : - 0; + $totalCount = $aggregationResult[$node->locationId] ?? 0; } else { $totalCount = $this->countSubitems($node->locationId); } From 6e089e2c9498ce0b175db724915c1816ad61882a Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 29 Jul 2021 14:57:10 +0200 Subject: [PATCH 07/10] CS fix --- src/lib/UI/Module/ContentTree/NodeFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 15a459d33e..25c99b4b0f 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -10,7 +10,6 @@ use eZ\Publish\API\Repository\ContentService; use eZ\Publish\API\Repository\Exceptions\NotImplementedException; -use eZ\Publish\API\Repository\Exceptions\OutOfBoundsException; use eZ\Publish\API\Repository\SearchService; use eZ\Publish\API\Repository\Values\Content\Location; use eZ\Publish\API\Repository\Values\Content\LocationQuery; From cd9d733ff7f5ac63f1727406d25806a3ed7cc0f2 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 4 Aug 2021 09:30:46 +0200 Subject: [PATCH 08/10] Fixups after CR --- src/lib/UI/Module/ContentTree/NodeFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index 25c99b4b0f..c1d37eac71 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -362,10 +362,10 @@ private function supplyTranslatedContentName(Node $node, array $contentById): vo /** * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException */ - private function supplyChildrenCount(Node $node, array $aggregationResult = null): void + private function supplyChildrenCount(Node $node, ?array $aggregationResult = null): void { if ($node->isContainer) { - if ($aggregationResult) { + if ($aggregationResult !== null) { $totalCount = $aggregationResult[$node->locationId] ?? 0; } else { $totalCount = $this->countSubitems($node->locationId); From 569292ad21f058d0890313bc013322def6873858 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 5 Aug 2021 10:37:47 +0200 Subject: [PATCH 09/10] Update src/lib/UI/Module/ContentTree/NodeFactory.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Wójs --- src/lib/UI/Module/ContentTree/NodeFactory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/UI/Module/ContentTree/NodeFactory.php b/src/lib/UI/Module/ContentTree/NodeFactory.php index c1d37eac71..6cfd8399fb 100644 --- a/src/lib/UI/Module/ContentTree/NodeFactory.php +++ b/src/lib/UI/Module/ContentTree/NodeFactory.php @@ -213,6 +213,9 @@ private function countAggregatedSubitems(array $containerLocations): array return []; } + /** + * @return array + */ private function aggregationResultToArray(TermAggregationResult $aggregationResult): array { $resultsAsArray = []; From 983479cf1dad9c1e6e2a0075024cf5e0570c0ba8 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 5 Aug 2021 11:06:35 +0200 Subject: [PATCH 10/10] Changed the parameter name to ibexa.admin_ui.content_tree.node_factory.max_location_ids_in_single_aggregation --- src/bundle/Resources/config/default_parameters.yaml | 2 +- src/bundle/Resources/config/services/modules/content_tree.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundle/Resources/config/default_parameters.yaml b/src/bundle/Resources/config/default_parameters.yaml index a0c8c715ab..01f86c3b63 100644 --- a/src/bundle/Resources/config/default_parameters.yaml +++ b/src/bundle/Resources/config/default_parameters.yaml @@ -75,4 +75,4 @@ parameters: ez_systems.multifile_upload.max_file_size: 5242880 - ezplatform.nodefactory.max_location_ids_in_single_aggregation: 100 + ibexa.admin_ui.content_tree.node_factory.max_location_ids_in_single_aggregation: 100 diff --git a/src/bundle/Resources/config/services/modules/content_tree.yaml b/src/bundle/Resources/config/services/modules/content_tree.yaml index 1352fb4ee7..1115e83627 100644 --- a/src/bundle/Resources/config/services/modules/content_tree.yaml +++ b/src/bundle/Resources/config/services/modules/content_tree.yaml @@ -9,7 +9,7 @@ services: $contentService: '@ezpublish.api.service.content' $translationHelper: '@ezpublish.translation_helper' $configResolver: '@ezpublish.config.resolver' - $maxLocationIdsInSingleAggregation: '%ezplatform.nodefactory.max_location_ids_in_single_aggregation%' + $maxLocationIdsInSingleAggregation: '%ibexa.admin_ui.content_tree.node_factory.max_location_ids_in_single_aggregation%' EzSystems\EzPlatformAdminUi\UI\Config\Provider\Module\ContentTree: tags: