From 181058c04d5c78682ba8187404d9bd313314c041 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Wed, 17 Jun 2020 14:00:06 +0300 Subject: [PATCH 1/8] mp-2855 added relationship --- .../ContentProduct/ContentProductClient.php | 17 +++++++++++ .../ContentProductClientInterface.php | 15 ++++++++++ ...entProductToContentStorageClientBridge.php | 11 ++++++++ ...ProductToContentStorageClientInterface.php | 14 ++++++++++ .../ContentProductAbstractListTypeMapper.php | 28 +++++++++++++++++++ ...ProductAbstractListTypeMapperInterface.php | 8 ++++++ 6 files changed, 93 insertions(+) diff --git a/src/Spryker/Client/ContentProduct/ContentProductClient.php b/src/Spryker/Client/ContentProduct/ContentProductClient.php index 23b89b930a5..f89b37199b9 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClient.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClient.php @@ -31,4 +31,21 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ ->createContentProductAbstractListTypeMapper() ->executeProductAbstractListTypeByKey($contentKey, $localeName); } + + /** + * {@inheritDoc} + * + * @api + * + * @param array $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..27fe6766f53 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php @@ -25,4 +25,19 @@ 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 item. + * - Executes stored term with found content items to get a content product abstract list type. + * + * @api + * + * @param array $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..7aacf5b724b 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php @@ -34,4 +34,15 @@ public function findContentTypeContextByKey(string $contentKey, string $localeNa { return $this->contentStorageClient->findContentTypeContextByKey($contentKey, $localeName); } + + /** + * @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..67b2bdf4bca 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php @@ -18,4 +18,18 @@ interface ContentProductToContentStorageClientInterface * @return \Generated\Shared\Transfer\ContentTypeContextTransfer|null */ public function findContentTypeContextByKey(string $contentKey, string $localeName): ?ContentTypeContextTransfer; + + /** + * Specification: + * - Retrieves content by keys through a storage client dependency. + * - Returns the context needed to generate a content type. + * + * @api + * + * @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..49471939e5d 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php @@ -61,4 +61,32 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ return $productAbstractListTermToProductAbstractListTypeExecutor->execute($contentTypeContextTransfer); } + + /** + * @param array $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(); + $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..c0ed94d117f 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php @@ -18,4 +18,12 @@ interface ContentProductAbstractListTypeMapperInterface * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer|null */ public function executeProductAbstractListTypeByKey(string $contentKey, string $localeName): ?ContentProductAbstractListTypeTransfer; + + /** + * @param array $contentKeys + * @param string $localeName + * + * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] + */ + public function executeProductAbstractListTypeByKeys(array $contentKeys, string $localeName): array; } From a772aafdbb3132d0bdaf569455bb89a9ce639efb Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Wed, 17 Jun 2020 15:51:47 +0300 Subject: [PATCH 2/8] mp-2855 add phpstan to annotations --- .../Client/ContentProduct/ContentProductClient.php | 6 +++++- .../ContentProduct/ContentProductClientInterface.php | 10 +++++++--- .../Mapper/ContentProductAbstractListTypeMapper.php | 6 +++++- .../ContentProductAbstractListTypeMapperInterface.php | 6 +++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Spryker/Client/ContentProduct/ContentProductClient.php b/src/Spryker/Client/ContentProduct/ContentProductClient.php index f89b37199b9..e817657608f 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClient.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClient.php @@ -37,7 +37,11 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ * * @api * - * @param array $contentKeys + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * + * @param string[] $contentKeys * @param string $localeName * * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] diff --git a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php index 27fe6766f53..5922a9e5244 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php @@ -29,12 +29,16 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ /** * Specification: * - Finds content items in the key-value storage by content keys and locale name. - * - Gets stored term for found content item. - * - Executes stored term with found content items to get a content product abstract list type. + * - 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 * - * @param array $contentKeys + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * + * @param string[] $contentKeys * @param string $localeName * * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php index 49471939e5d..4c42d05d25c 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php @@ -63,7 +63,11 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ } /** - * @param array $contentKeys + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * + * @param string[] $contentKeys * @param string $localeName * * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php index c0ed94d117f..876fb42f365 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php @@ -20,7 +20,11 @@ interface ContentProductAbstractListTypeMapperInterface public function executeProductAbstractListTypeByKey(string $contentKey, string $localeName): ?ContentProductAbstractListTypeTransfer; /** - * @param array $contentKeys + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * + * @param string[] $contentKeys * @param string $localeName * * @return \Generated\Shared\Transfer\ContentProductAbstractListTypeTransfer[] From e4140792655e4ad74c147244ce358951fc21ef51 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Wed, 17 Jun 2020 16:14:48 +0300 Subject: [PATCH 3/8] mp2855 update phpstan annotations --- .../Client/ContentProductToContentStorageClientBridge.php | 4 ++++ .../Client/ContentProductToContentStorageClientInterface.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php index 7aacf5b724b..e74a7bbad00 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php @@ -36,6 +36,10 @@ public function findContentTypeContextByKey(string $contentKey, string $localeNa } /** + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * * @param string[] $contentKeys * @param string $localeName * diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php index 67b2bdf4bca..4f8d4a01c61 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php @@ -26,6 +26,10 @@ public function findContentTypeContextByKey(string $contentKey, string $localeNa * * @api * + * @phpstan-param array $contentKeys + * + * @phpstan-return array + * * @param string[] $contentKeys * @param string $localeName * From 1eb1b1168c4dc8a6ec5ba3e36b0eda43cfe31ce4 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Wed, 17 Jun 2020 17:15:26 +0300 Subject: [PATCH 4/8] mp-2855 fixes after self review --- .../Mapper/ContentProductAbstractListTypeMapper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php index 4c42d05d25c..42600d34536 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php @@ -86,6 +86,10 @@ public function executeProductAbstractListTypeByKeys(array $contentKeys, string $contentProductAbstractListTypeTransfers = []; foreach ($contentTypeContextTransfers as $contentTypeContextTransfer) { $term = $contentTypeContextTransfer->getTerm(); + if (!isset($this->contentProductTermExecutors[$term])) { + return []; + } + $productAbstractListTermToBannerTypeExecutor = $this->contentProductTermExecutors[$term]; $contentProductAbstractListTypeTransfers[$contentTypeContextTransfer->getKey()] = $productAbstractListTermToBannerTypeExecutor->execute($contentTypeContextTransfer); From 3f6c19d1e464cca59d0bc5a39a06fbe618d9e003 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Thu, 18 Jun 2020 11:39:11 +0300 Subject: [PATCH 5/8] mp-2855 fixes after dev cr --- .../ContentProductToContentStorageClientInterface.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php index 4f8d4a01c61..74636aca39b 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php @@ -20,12 +20,6 @@ interface ContentProductToContentStorageClientInterface public function findContentTypeContextByKey(string $contentKey, string $localeName): ?ContentTypeContextTransfer; /** - * Specification: - * - Retrieves content by keys through a storage client dependency. - * - Returns the context needed to generate a content type. - * - * @api - * * @phpstan-param array $contentKeys * * @phpstan-return array From a57d95ffb00d771b4a6479d53d1a55deb5d0dd57 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Tue, 23 Jun 2020 12:36:10 +0300 Subject: [PATCH 6/8] mp-2855 fixes after self review --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5f282dcbe08..c3dcdcf1137 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.3.0", "spryker/kernel": "^3.32.0" }, "require-dev": { From 4e3c31551c3111fd987c8f553bdc4adeecc1add8 Mon Sep 17 00:00:00 2001 From: Kotiuk Date: Tue, 23 Jun 2020 17:56:54 +0300 Subject: [PATCH 7/8] mp-2855 fix comments after TL review --- src/Spryker/Client/ContentProduct/ContentProductClient.php | 2 -- .../Client/ContentProduct/ContentProductClientInterface.php | 2 -- .../Client/ContentProductToContentStorageClientBridge.php | 2 -- .../Client/ContentProductToContentStorageClientInterface.php | 2 -- .../Mapper/ContentProductAbstractListTypeMapper.php | 2 -- .../Mapper/ContentProductAbstractListTypeMapperInterface.php | 2 -- 6 files changed, 12 deletions(-) diff --git a/src/Spryker/Client/ContentProduct/ContentProductClient.php b/src/Spryker/Client/ContentProduct/ContentProductClient.php index e817657608f..0d8c2ba5699 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClient.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClient.php @@ -37,8 +37,6 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ * * @api * - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys diff --git a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php index 5922a9e5244..c32a7e1a35a 100644 --- a/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php +++ b/src/Spryker/Client/ContentProduct/ContentProductClientInterface.php @@ -34,8 +34,6 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ * * @api * - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php index e74a7bbad00..d84ee480185 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientBridge.php @@ -36,8 +36,6 @@ public function findContentTypeContextByKey(string $contentKey, string $localeNa } /** - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys diff --git a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php index 74636aca39b..d6986a193b6 100644 --- a/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php +++ b/src/Spryker/Client/ContentProduct/Dependency/Client/ContentProductToContentStorageClientInterface.php @@ -20,8 +20,6 @@ interface ContentProductToContentStorageClientInterface public function findContentTypeContextByKey(string $contentKey, string $localeName): ?ContentTypeContextTransfer; /** - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php index 42600d34536..07c40f7e67d 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapper.php @@ -63,8 +63,6 @@ public function executeProductAbstractListTypeByKey(string $contentKey, string $ } /** - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys diff --git a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php index 876fb42f365..efb8b93bab1 100644 --- a/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php +++ b/src/Spryker/Client/ContentProduct/Mapper/ContentProductAbstractListTypeMapperInterface.php @@ -20,8 +20,6 @@ interface ContentProductAbstractListTypeMapperInterface public function executeProductAbstractListTypeByKey(string $contentKey, string $localeName): ?ContentProductAbstractListTypeTransfer; /** - * @phpstan-param array $contentKeys - * * @phpstan-return array * * @param string[] $contentKeys From 7e5275310810afc37be86dda8796be24115ce31d Mon Sep 17 00:00:00 2001 From: Eugenia Poidenko Date: Fri, 3 Jul 2020 15:16:11 +0300 Subject: [PATCH 8/8] MP-2848 upped the constraint versions. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c3dcdcf1137..84a23f19f4f 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "proprietary", "require": { "php": ">=7.2", - "spryker/content-storage": "^2.3.0", + "spryker/content-storage": "^2.4.0", "spryker/kernel": "^3.32.0" }, "require-dev": {