Skip to content

Commit

Permalink
PBC-1978: Fixed Product and SearchHttp modules to be ready to work wi…
Browse files Browse the repository at this point in the history
…th Dynamic Multi Store (#10342)

PBC-1978 Fixed Product and SearchHttp modules to be ready to work with Dynamic Multi Store
  • Loading branch information
pushokwhite authored Aug 11, 2023
1 parent 4bf29d8 commit b8f1d7c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/Spryker/Zed/Store/Business/StoreFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ public function getStoreByStoreReference(string $storeReference): StoreTransfer
*
* @api
*
* @deprecated Will be removed without replacement.
*
* @param \Generated\Shared\Transfer\AccessTokenRequestTransfer $accessTokenRequestTransfer
* @throws \Spryker\Zed\Store\Business\Exception\StoreReferenceNotFoundException
Expand All @@ -289,6 +291,10 @@ public function getStoreByStoreReference(string $storeReference): StoreTransfer
*/
public function expandAccessTokenRequest(AccessTokenRequestTransfer $accessTokenRequestTransfer): AccessTokenRequestTransfer
{
if ($this->isDynamicStoreEnabled()) {
return $accessTokenRequestTransfer;
}

return $this->getFactory()
->createStoreReferenceAccessTokenRequestExpander()
->expand($accessTokenRequestTransfer);
Expand All @@ -313,13 +319,19 @@ public function validateMessageTransfer(TransferInterface $messageTransfer): Mes
*
* @api
*
* @deprecated Will be removed without replacement.
*
* @param \Generated\Shared\Transfer\MessageAttributesTransfer $messageAttributesTransfer
*
* @return \Generated\Shared\Transfer\MessageAttributesTransfer
*/
public function expandMessageAttributes(
MessageAttributesTransfer $messageAttributesTransfer
): MessageAttributesTransfer {
if ($this->isDynamicStoreEnabled()) {
return $messageAttributesTransfer;
}

return $this->getFactory()
->createCurrentStoreReferenceMessageAttributesExpander()
->expand($messageAttributesTransfer);
Expand Down
6 changes: 6 additions & 0 deletions src/Spryker/Zed/Store/Business/StoreFacadeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,15 @@ public function getStoreByStoreReference(string $storeReference): StoreTransfer;

/**
* Specification:
* - Expands only if dynamic store is disabled.
* - Finds a store reference for the currently selected store.
* - Expands `AccessTokenRequest.accessTokenRequestOptions` with found store reference.
* - Executes stack of {@link \Spryker\Zed\StoreExtension\Dependency\Plugin\StoreCollectionExpanderPluginInterface} plugins.
*
* @api
*
* @deprecated Will be removed without replacement.
*
* @param \Generated\Shared\Transfer\AccessTokenRequestTransfer $accessTokenRequestTransfer
*
* @return \Generated\Shared\Transfer\AccessTokenRequestTransfer
Expand All @@ -273,11 +276,14 @@ public function validateMessageTransfer(TransferInterface $messageTransfer): Mes

/**
* Specification:
* - Expands only if dynamic store is disabled.
* - When store reference is not provided, expands message attributes with store reference from a store set in the application environment.
* - Executes stack of {@link \Spryker\Zed\StoreExtension\Dependency\Plugin\StoreCollectionExpanderPluginInterface} plugins.
*
* @api
*
* @deprecated Will be removed without replacement.
*
* @param \Generated\Shared\Transfer\MessageAttributesTransfer $messageAttributesTransfer
*
* @return \Generated\Shared\Transfer\MessageAttributesTransfer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class GatewayController extends AbstractGatewayController
{
/**
* @param \Generated\Shared\Transfer\StoreCriteriaTransfer $storeCriteriaTransfer
*
* @return \Generated\Shared\Transfer\StoreCollectionTransfer
*/
public function getStoreCollectionAction(StoreCriteriaTransfer $storeCriteriaTransfer): StoreCollectionTransfer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Spryker\Zed\MessageBrokerExtension\Dependency\Plugin\MessageAttributeProviderPluginInterface;

/**
* @deprecated Will be removed without replacement.
*
* @method \Spryker\Zed\Store\StoreConfig getConfig()
* @method \Spryker\Zed\Store\Business\StoreFacadeInterface getFacade()
* @method \Spryker\Zed\Store\Communication\StoreCommunicationFactory getFactory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Spryker\Zed\OauthClientExtension\Dependency\Plugin\AccessTokenRequestExpanderPluginInterface;

/**
* @deprecated Will be removed without replacement.
*
* @method \Spryker\Zed\Store\Business\StoreFacadeInterface getFacade()
* @method \Spryker\Zed\Store\StoreConfig getConfig()
* @method \Spryker\Zed\Store\Communication\StoreCommunicationFactory getFactory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CurrentStoreReferenceMessageAttributeProviderPluginTest extends Unit
public function testProvideMessageAttributesAddsStoreReferenceWhenItExists(): void
{
// Arrange
$this->mockCurrentStore(static::STORE_NAME, static::STORE_REFERENCE_NAME);
$this->mockCurrentStore(false, static::STORE_NAME, static::STORE_REFERENCE_NAME);

$messageAttributesTransfer = new MessageAttributesTransfer();
$storeReferenceMessageAttributeProviderPlugin = new CurrentStoreReferenceMessageAttributeProviderPlugin();
Expand All @@ -67,7 +67,7 @@ public function testProvideMessageAttributesAddsStoreReferenceWhenItExists(): vo
public function testProvideMessageAttributesDoesNotAddStoreReferenceWhenTenantIdentifierDoesNotExists(): void
{
// Arrange
$this->mockCurrentStore('aaa', null);
$this->mockCurrentStore(false, 'aaa', null);

$messageAttributesTransfer = new MessageAttributesTransfer();
$storeReferenceMessageAttributeProviderPlugin = new CurrentStoreReferenceMessageAttributeProviderPlugin();
Expand All @@ -81,12 +81,32 @@ public function testProvideMessageAttributesDoesNotAddStoreReferenceWhenTenantId
}

/**
* @return void
*/
public function testProvideMessageAttributesDoesNotAddStoreReferenceWhenDynamicMultiStoreEnabled(): void
{
// Arrange
$this->mockCurrentStore(true, static::STORE_NAME, static::STORE_REFERENCE_NAME);

$messageAttributesTransfer = new MessageAttributesTransfer();
$storeReferenceMessageAttributeProviderPlugin = new CurrentStoreReferenceMessageAttributeProviderPlugin();
$storeReferenceMessageAttributeProviderPlugin->setFacade($this->tester->getFacade());

// Act
$messageAttributesTransfer = $storeReferenceMessageAttributeProviderPlugin->provideMessageAttributes($messageAttributesTransfer);

// Assert
$this->assertNull($messageAttributesTransfer->getStoreReference());
}

/**
* @param bool $isDynamicStoreModeEnabled
* @param string $storeName
* @param string|null $storeReference
*
* @return void
*/
protected function mockCurrentStore(string $storeName, ?string $storeReference): void
protected function mockCurrentStore(bool $isDynamicStoreModeEnabled, string $storeName, ?string $storeReference): void
{
$storeReaderMock = $this->getMockBuilder(StoreReader::class)
->disableOriginalConstructor()
Expand All @@ -99,5 +119,6 @@ protected function mockCurrentStore(string $storeName, ?string $storeReference):

$this->tester->mockFactoryMethod('createStoreReader', $storeReaderMock);
$this->tester->mockFactoryMethod('getCurrentStore', static::STORE_NAME);
$this->tester->mockFactoryMethod('getIsDynamicStoreModeEnabled', $isDynamicStoreModeEnabled);
}
}

0 comments on commit b8f1d7c

Please sign in to comment.