Skip to content

Commit

Permalink
FRW-8594 Fixed Dynamic Store ON/OFF mode inconsistencies. (#11006)
Browse files Browse the repository at this point in the history
FRW-8594 Fixed Dynamic Store ON/OFF mode inconsistencies.
  • Loading branch information
dimitriyTsemma authored Aug 2, 2024
1 parent 130bf55 commit 9854ac0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 50 deletions.
14 changes: 1 addition & 13 deletions src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Spryker\Zed\Locale\Business\Expander;

use Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface;
use Spryker\Zed\Locale\Persistence\LocaleRepositoryInterface;

class StoreExpander implements StoreExpanderInterface
Expand All @@ -17,19 +16,12 @@ class StoreExpander implements StoreExpanderInterface
*/
protected LocaleRepositoryInterface $localeRepository;

/**
* @var \Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface
*/
protected LocaleToStoreFacadeInterface $storeFacade;

/**
* @param \Spryker\Zed\Locale\Persistence\LocaleRepositoryInterface $localeRepository
* @param \Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface $storeFacade
*/
public function __construct(LocaleRepositoryInterface $localeRepository, LocaleToStoreFacadeInterface $storeFacade)
public function __construct(LocaleRepositoryInterface $localeRepository)
{
$this->localeRepository = $localeRepository;
$this->storeFacade = $storeFacade;
}

/**
Expand All @@ -39,10 +31,6 @@ public function __construct(LocaleRepositoryInterface $localeRepository, LocaleT
*/
public function expandStoreTransfersWithLocales(array $storeTransfers): array
{
if (!$this->storeFacade->isDynamicStoreEnabled()) {
return $storeTransfers;
}

$storeIds = [];

foreach ($storeTransfers as $storeTransfer) {
Expand Down
3 changes: 1 addition & 2 deletions src/Spryker/Zed/Locale/Business/LocaleBusinessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function createLocaleWriter(): LocaleWriterInterface
return new LocaleWriter(
$this->createLocaleReader(),
$this->getEntityManager(),
$this->getStoreFacade(),
);
}

Expand Down Expand Up @@ -103,7 +102,7 @@ public function createLocaleValidator(): LocaleValidatorInterface
*/
public function createStoreExpander(): StoreExpanderInterface
{
return new StoreExpander($this->getRepository(), $this->getStoreFacade());
return new StoreExpander($this->getRepository());
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Spryker/Zed/Locale/Business/LocaleFacadeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public function getSupportedLocaleCodes(): array;
/**
* Specification:
* - Expands collection of store transfers with available locale codes.
* - Expands collection only if `Dynamic Store` is enabled
*
* @api
*
Expand Down
19 changes: 1 addition & 18 deletions src/Spryker/Zed/Locale/Business/Writer/LocaleWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Generated\Shared\Transfer\StoreTransfer;
use Spryker\Zed\Locale\Business\Exception\LocaleExistsException;
use Spryker\Zed\Locale\Business\Reader\LocaleReaderInterface;
use Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface;
use Spryker\Zed\Locale\Persistence\LocaleEntityManagerInterface;

class LocaleWriter implements LocaleWriterInterface
Expand All @@ -29,24 +28,16 @@ class LocaleWriter implements LocaleWriterInterface
*/
protected LocaleEntityManagerInterface $localeEntityManager;

/**
* @var \Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface
*/
protected LocaleToStoreFacadeInterface $storeFacade;

/**
* @param \Spryker\Zed\Locale\Business\Reader\LocaleReaderInterface $localeReader
* @param \Spryker\Zed\Locale\Persistence\LocaleEntityManagerInterface $localeEntityManager
* @param \Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface $storeFacade
*/
public function __construct(
LocaleReaderInterface $localeReader,
LocaleEntityManagerInterface $localeEntityManager,
LocaleToStoreFacadeInterface $storeFacade
LocaleEntityManagerInterface $localeEntityManager
) {
$this->localeReader = $localeReader;
$this->localeEntityManager = $localeEntityManager;
$this->storeFacade = $storeFacade;
}

/**
Expand Down Expand Up @@ -80,10 +71,6 @@ public function createLocaleStore(StoreTransfer $storeTransfer): StoreResponseTr
*/
public function updateStoreLocales(StoreTransfer $storeTransfer): StoreResponseTransfer
{
if (!$this->storeFacade->isDynamicStoreEnabled()) {
return $this->getSuccessfulResponse($storeTransfer);
}

$localeTransfers = $this->localeReader->getLocaleCollection(
(new LocaleCriteriaTransfer())
->setLocaleConditions((new LocaleConditionsTransfer())
Expand Down Expand Up @@ -124,10 +111,6 @@ public function deleteLocale(string $localeName): void
*/
public function updateStoreDefaultLocale(StoreTransfer $storeTransfer): StoreResponseTransfer
{
if (!$this->storeFacade->isDynamicStoreEnabled()) {
return $this->getSuccessfulResponse($storeTransfer);
}

$localeTransfer = $this->localeReader->getLocaleByName($storeTransfer->getDefaultLocaleIsoCodeOrFail());

$this->localeEntityManager->updateStoreDefaultLocale(
Expand Down
16 changes: 0 additions & 16 deletions tests/SprykerTest/Zed/Locale/Business/LocaleFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ public function testAvailableLocalesToBeArrayType(): void
*/
public function testUpdateStoreLocalesWithAddingNewAndRemovingOldRelations(): void
{
if ($this->tester->isDynamicStoreEnabled() === false) {
$this->markTestSkipped('Test is valid for Dynamic Store on-mode only.');
}

// Arrange
$storeTransfer = $this->tester->haveStore([StoreTransfer::NAME => static::STORE_NAME_DE]);
$this->tester->deleteLocaleStore($storeTransfer->getIdStoreOrFail());
Expand Down Expand Up @@ -156,10 +152,6 @@ public function testUpdateStoreLocalesWithAddingNewAndRemovingOldRelations(): vo
*/
public function testExpandStoreTransfersWithLocalesSuccessful(): void
{
if ($this->tester->isDynamicStoreEnabled() === false) {
$this->markTestSkipped('Test is valid for Dynamic Store on-mode only.');
}

// Arrange
$storeTransferEu = $this->tester->haveStore([StoreTransfer::NAME => static::STORE_NAME_DE]);

Expand All @@ -182,10 +174,6 @@ public function testExpandStoreTransfersWithLocalesSuccessful(): void
*/
public function testExpandStoreTransfersWithLocalesWithoutLocaleStoreRelations(): void
{
if ($this->tester->isDynamicStoreEnabled() === false) {
$this->markTestSkipped('Test is valid for Dynamic Store on-mode only.');
}

// Arrange
$storeTransferEu = $this->tester->haveStore([StoreTransfer::NAME => static::STORE_NAME_DE]);

Expand Down Expand Up @@ -266,10 +254,6 @@ public function testValidateStoreLocaleWithInvalidDefaultLocale(): void
*/
public function testUpdateStoreDefaultLocaleSuccessful(): void
{
if ($this->tester->isDynamicStoreEnabled() === false) {
$this->markTestSkipped('Test is valid for Dynamic Store on-mode only.');
}

// Arrange
$storeTransfer = $this->tester->haveStore([StoreTransfer::NAME => static::STORE_NAME_DE]);
$idLocaleDe = $this->tester->haveLocale([LocaleTransfer::LOCALE_NAME => static::LOCALE_DE])->getIdLocaleOrFail();
Expand Down

0 comments on commit 9854ac0

Please sign in to comment.