-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5587 from spryker/feature/te-3719/master-cart-pag…
…e-optimisations TE-3719 Cart page and Add to cart optimization
- Loading branch information
Showing
9 changed files
with
158 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\Locale\Persistence; | ||
|
||
use Generated\Shared\Transfer\LocaleTransfer; | ||
use Propel\Runtime\Collection\ObjectCollection; | ||
use Spryker\Zed\Kernel\Persistence\AbstractRepository; | ||
|
||
/** | ||
* @method \Spryker\Zed\Locale\Persistence\LocalePersistenceFactory getFactory() | ||
*/ | ||
class LocaleRepository extends AbstractRepository implements LocaleRepositoryInterface | ||
{ | ||
/** | ||
* @param string[] $localeNames | ||
* | ||
* @return \Generated\Shared\Transfer\LocaleTransfer[] | ||
*/ | ||
public function getLocaleTransfersByLocaleNames(array $localeNames): array | ||
{ | ||
$localeEntities = $this->getFactory()->createLocaleQuery() | ||
->filterByLocaleName_In($localeNames) | ||
->find(); | ||
|
||
return $this->mapLocaleEntitiesToLocaleTransfers($localeEntities); | ||
} | ||
|
||
/** | ||
* @param \Orm\Zed\Locale\Persistence\SpyLocale[]|\Propel\Runtime\Collection\ObjectCollection $localeEntities | ||
* | ||
* @return \Generated\Shared\Transfer\LocaleTransfer[] | ||
*/ | ||
protected function mapLocaleEntitiesToLocaleTransfers(ObjectCollection $localeEntities): array | ||
{ | ||
$localeTransfers = []; | ||
$localeMapper = $this->getFactory()->createLocaleMapper(); | ||
|
||
foreach ($localeEntities as $localeEntity) { | ||
$localeTransfer = new LocaleTransfer(); | ||
$localeTransfer = $localeMapper->mapLocaleEntityToLocaleTransfer($localeEntity, $localeTransfer); | ||
|
||
$localeTransfers[] = $localeTransfer; | ||
} | ||
|
||
return $localeTransfers; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Spryker/Zed/Locale/Persistence/LocaleRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\Locale\Persistence; | ||
|
||
interface LocaleRepositoryInterface | ||
{ | ||
/** | ||
* @param string[] $localeNames | ||
* | ||
* @return \Generated\Shared\Transfer\LocaleTransfer[] | ||
*/ | ||
public function getLocaleTransfersByLocaleNames(array $localeNames): array; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Spryker/Zed/Locale/Persistence/Propel/Mapper/LocaleMapper.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\Locale\Persistence\Propel\Mapper; | ||
|
||
use Generated\Shared\Transfer\LocaleTransfer; | ||
use Orm\Zed\Locale\Persistence\SpyLocale; | ||
|
||
class LocaleMapper | ||
{ | ||
/** | ||
* @param \Orm\Zed\Locale\Persistence\SpyLocale $localeEntity | ||
* @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\LocaleTransfer | ||
*/ | ||
public function mapLocaleEntityToLocaleTransfer(SpyLocale $localeEntity, LocaleTransfer $localeTransfer): LocaleTransfer | ||
{ | ||
return $localeTransfer->fromArray($localeEntity->toArray(), true); | ||
} | ||
} |