diff --git a/composer.json b/composer.json index 5f282dcbe08..84a23f19f4f 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "proprietary", "require": { "php": ">=7.2", - "spryker/content-storage": "^2.0.0", + "spryker/content-storage": "^2.4.0", "spryker/kernel": "^3.32.0" }, "require-dev": { diff --git a/src/Spryker/Client/ContentProduct/ContentProductClient.php b/src/Spryker/Client/ContentProduct/ContentProductClient.php index 23b89b930a5..0d8c2ba5699 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClient.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClient.php @@ -31,4 +31,23 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ ->createContentProductAbstractListTypeMapper() ->executeProductAbstractListTypeByKey($contentKey, $localeName); } + + /** + * {@inheritDoc} + * + * @api + * + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] + */ + public function executeProductAbstractListTypeByKeys(array $contentKeys, string $localeName): array + { + return $this->getFactory() + ->createContentProductAbstractListTypeMapper() + ->executeProductAbstractListTypeByKeys($contentKeys, $localeName); + } } diff --git a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php index cfc62fe815e..c32a7e1a35a 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php @@ -25,4 +25,21 @@ interface ContentProductClientInterface * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer|null */ public function executeProductAbstractListTypeByKey(string $contentKey, string $localeName): ?ContentProductAbstractListTypeTransfer; + + /** + * Specification: + * - Finds content items in the key-value storage by content keys and locale name. + * - Gets stored term for found content items. + * - Executes stored term with found content items to get a collection of content product abstract list type. + * + * @api + * + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] + */ + public function executeProductAbstractListTypeByKeys(array $contentKeys, string $localeName): array; } diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php index 3de0bca2f26..d84ee480185 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php @@ -34,4 +34,17 @@ public function findContentTypeContextByKey(string $contentKey, string $localeNa { return $this->contentStorageClient->findContentTypeContextByKey($contentKey, $localeName); } + + /** + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentTypeContextTransfer[] + */ + public function getContentTypeContextByKeys(array $contentKeys, string $localeName): array + { + return $this->contentStorageClient->getContentTypeContextByKeys($contentKeys, $localeName); + } } diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php index 9f8274920ed..d6986a193b6 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php @@ -18,4 +18,14 @@ interface ContentProductToContentStorageClientInterface * @return \Generated\Shared\Transfer\ContentTypeContextTransfer|null */ public function findContentTypeContextByKey(string $contentKey, string $localeName): ?ContentTypeContextTransfer; + + /** + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentTypeContextTransfer[] + */ + public function getContentTypeContextByKeys(array $contentKeys, string $localeName): array; } diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php index 5f50c794a25..07c40f7e67d 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php @@ -61,4 +61,38 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ return $productAbstractListTermToProductAbstractListTypeExecutor->execute($contentTypeContextTransfer); } + + /** + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] + */ + public function executeProductAbstractListTypeByKeys(array $contentKeys, string $localeName): array + { + $contentTypeContextTransfers = $this->contentStorageClient->getContentTypeContextByKeys( + $contentKeys, + $localeName + ); + + if (!$contentTypeContextTransfers) { + return []; + } + + $contentProductAbstractListTypeTransfers = []; + foreach ($contentTypeContextTransfers as $contentTypeContextTransfer) { + $term = $contentTypeContextTransfer->getTerm(); + if (!isset($this->contentProductTermExecutors[$term])) { + return []; + } + + $productAbstractListTermToBannerTypeExecutor = $this->contentProductTermExecutors[$term]; + + $contentProductAbstractListTypeTransfers[$contentTypeContextTransfer->getKey()] = $productAbstractListTermToBannerTypeExecutor->execute($contentTypeContextTransfer); + } + + return $contentProductAbstractListTypeTransfers; + } } diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php index 240106a28c5..efb8b93bab1 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php @@ -18,4 +18,14 @@ interface ContentProductAbstractListTypeMapperInterface * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer|null */ public function executeProductAbstractListTypeByKey(string $contentKey, string $localeName): ?ContentProductAbstractListTypeTransfer; + + /** + * @phpstan-return array + * + * @param string[] $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] + */ + public function executeProductAbstractListTypeByKeys(array $contentKeys, string $localeName): array; }