-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/Pyz/Zed/ProductDetailWidget/Business/Exception/KeyExistsException.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,14 @@ | ||
<?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 Pyz\Zed\ProductDetailPageWidget\Business\Exception; | ||
|
||
use Exception; | ||
|
||
class KeyExistsException extends Exception | ||
{ | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Pyz/Zed/ProductDetailWidget/Business/Exception/MissingKeyException.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,15 @@ | ||
<?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 Pyz\Zed\ProductDetailPageWidget\Business\Exception; | ||
|
||
use Exception; | ||
|
||
class MissingKeyException extends Exception | ||
{ | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Pyz/Zed/ProductDetailWidget/Business/Manager/ProductDetailManager.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,45 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © [year]-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Business\Manager; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
use Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailEntityManagerInterface; | ||
use Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailRepositoryInterface; | ||
|
||
class ProductDetailManager implements ProductDetailManagerInterface | ||
{ | ||
/** | ||
* @var \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailRepositoryInterface | ||
*/ | ||
protected $productDetailRepository; | ||
|
||
/** | ||
* @var \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailEntityManagerInterface | ||
*/ | ||
protected $productDetailEntityManager; | ||
|
||
/** | ||
* @param \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailRepositoryInterface $productDetailRepository | ||
* @param \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailEntityManagerInterface $productDetailEntityManager | ||
*/ | ||
public function __construct( | ||
ProductDetailRepositoryInterface $productDetailRepository, | ||
ProductDetailEntityManagerInterface $productDetailEntityManager | ||
) { | ||
$this->productDetailRepository = $productDetailRepository; | ||
$this->productDetailEntityManager = $productDetailEntityManager; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findProductAbstractById(int $idProductAbstract): ?ProductAbstractTransfer | ||
{ | ||
return $this->productDetailRepository->findProductAbstractById($idProductAbstract); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Pyz/Zed/ProductDetailWidget/Business/Manager/ProductDetailManagerInterface.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,19 @@ | ||
<?php | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Business\Manager; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
|
||
interface ProductDetailManagerInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Finds a product abstract by its ID. | ||
* - Returns the ProductAbstractTransfer if found, null otherwise. | ||
* | ||
* @param int $idProductAbstract | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer|null | ||
*/ | ||
public function findProductAbstractById(int $idProductAbstract): ?ProductAbstractTransfer; | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Pyz/Zed/ProductDetailWidget/Business/ProductDetailWidgetBusinessFactory.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,43 @@ | ||
<?php | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Business; | ||
|
||
use Pyz\Zed\ProductDetailPageWidget\Business\Manager\ProductDetailManager; | ||
use Pyz\Zed\ProductDetailPageWidget\Business\Manager\ProductDetailManagerInterface; | ||
use Pyz\Zed\ProductDetailPageWidget\Business\Reader\ProductDetailWriter; | ||
use Pyz\Zed\ProductDetailPageWidget\Business\Writer\ProductDetailPageWriterInterface; | ||
use Pyz\Zed\ProductDetailPageWidget\Business\Writer\ProductDetailPageWriter; | ||
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; | ||
|
||
/** | ||
* @method \Pyz\Zed\ProductDetailPageWidget\ProductDetailWidgetConfig getConfig() | ||
* @method \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailRepositoryInterface getRepository() | ||
* @method \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailEntityManagerInterface getEntityManager() | ||
*/ | ||
class ProductDetailWidgetBusinessFactory extends AbstractBusinessFactory | ||
{ | ||
/** | ||
* @return \Pyz\Zed\ProductDetailPageWidget\Business\Manager\ProductDetailManagerInterface | ||
*/ | ||
public function createProductDetailManager(): ProductDetailManagerInterface | ||
{ | ||
return new ProductDetailManager( | ||
$this->getRepository(), | ||
$this->getEntityManager() | ||
); | ||
} | ||
|
||
/** | ||
* @return \Pyz\Zed\ProductDetailPageWidget\Business\Reader\ProductDetailWriterInterface | ||
*/ | ||
public function createProductDetailReader(): ProductDetailPageWriterInterface | ||
{ | ||
return new ProductDetailWriter($this->getRepository()); | ||
} | ||
|
||
|
||
public function createProductWriter(): ProductDetailPageWriterInterface | ||
{ | ||
return new ProductDetailPageWriter($this->getEntityManager()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Pyz/Zed/ProductDetailWidget/Business/ProductDetailWidgetFacade.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,41 @@ | ||
<?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 Pyz\Zed\ProductDetailPageWidget\Business; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
use Spryker\Zed\Kernel\Business\AbstractFacade; | ||
|
||
/** | ||
* @method \Pyz\Zed\ProductDetailPageWidget\Business\ProductDetailWidgetBusinessFactory getFactory() | ||
* @method \Pyz\Zed\ProductDetailPageWidget\Persistence\ProductDetailRepositoryInterface getRepository() | ||
*/ | ||
class ProductDetailWidgetFacade extends AbstractFacade implements ProductDetailWidgetFacadeInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findProductAbstractById(int $idProductAbstract): ?ProductAbstractTransfer | ||
{ | ||
return $this->getRepository()->findProductAbstractById($idProductAbstract); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer | ||
* @api | ||
*/ | ||
public function saveProduct(ProductAbstractTransfer $productTransfer): ProductAbstractTransfer | ||
{ | ||
$productManager = $this->getFactory()->createProductDetailManager(); | ||
|
||
return $productManager->saveProduct($productTransfer); // Ensure this method exists in ProductManager | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Pyz/Zed/ProductDetailWidget/Business/ProductDetailWidgetFacadeInterface.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,21 @@ | ||
<?php | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Business; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
|
||
interface ProductDetailWidgetFacadeInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Finds a book entity by ID. | ||
* - Returns null if the book entity does not exist. | ||
* | ||
* @param int $idProductAbstract | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer|null | ||
*@api | ||
* | ||
*/ | ||
public function findProductAbstractById(int $idProductAbstract): ?ProductAbstractTransfer; | ||
} |
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 @@ | ||
<?php |
24 changes: 24 additions & 0 deletions
24
src/Pyz/Zed/ProductDetailWidget/Business/Reader/ProductDetailPageReaderInterface.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,24 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © [year]-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Pyz\Zed\ProductDetailWidget\Business\Reader; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
|
||
interface ProductDetailPageReaderInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Finds a product abstract by its ID. | ||
* - Returns a ProductDetailPageResponseTransfer containing product details and status. | ||
* | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer | ||
*/ | ||
public function findProductAbstractById(ProductAbstractTransfer $productAbstractTransfer): ProductAbstractTransfer; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Pyz/Zed/ProductDetailWidget/Dependency/Facade/ProductDetailWidgetToStoreFacadeBridge.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,35 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © [year]-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Dependency\Facade; | ||
|
||
use Generated\Shared\Transfer\StoreTransfer; | ||
use Spryker\Zed\Store\Business\StoreFacadeInterface; | ||
|
||
class ProductDetailWidgetToStoreFacadeBridge implements ProductDetailWidgetToStoreFacadeInterface | ||
{ | ||
/** | ||
* @var \Spryker\Zed\Store\Business\StoreFacadeInterface | ||
*/ | ||
protected $storeFacade; | ||
|
||
/** | ||
* @param \Spryker\Zed\Store\Business\StoreFacadeInterface $storeFacade | ||
*/ | ||
public function __construct(StoreFacadeInterface $storeFacade) | ||
{ | ||
$this->storeFacade = $storeFacade; | ||
} | ||
|
||
/** | ||
* @return \Generated\Shared\Transfer\StoreTransfer | ||
*/ | ||
public function getCurrentStore(): StoreTransfer | ||
{ | ||
return $this->storeFacade->getCurrentStore(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...z/Zed/ProductDetailWidget/Dependency/Facade/ProductDetailWidgetToStoreFacadeInterface.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,23 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © [year]-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Dependency\Facade; | ||
|
||
use Generated\Shared\Transfer\StoreTransfer; | ||
|
||
interface ProductDetailWidgetToStoreFacadeInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Returns the current store information. | ||
* | ||
* @api | ||
* | ||
* @return \Generated\Shared\Transfer\StoreTransfer | ||
*/ | ||
public function getCurrentStore(): StoreTransfer; | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Pyz/Zed/ProductDetailWidget/Persistence/Mapper/ProductAbstractMapper.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,49 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © [year]-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Persistence\Mapper; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
use Generated\Shared\Transfer\ProductAbstractCollectionTransfer; | ||
use Orm\Zed\Product\Persistence\SpyProductAbstract; | ||
use Propel\Runtime\Collection\Collection; | ||
|
||
class ProductAbstractMapper implements ProductAbstractMapperInterface | ||
{ | ||
/** | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer | ||
* @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstractEntity | ||
* | ||
* @return \Orm\Zed\Product\Persistence\SpyProductAbstract | ||
*/ | ||
public function mapProductAbstractTransferToEntity( | ||
ProductAbstractTransfer $productAbstractTransfer, | ||
SpyProductAbstract $productAbstractEntity | ||
): SpyProductAbstract { | ||
$productAbstractEntity->fromArray( | ||
$productAbstractTransfer->modifiedToArray(false), | ||
); | ||
|
||
return $productAbstractEntity; | ||
} | ||
|
||
/** | ||
* @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstractEntity | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer | ||
*/ | ||
public function mapEntityToProductAbstractTransfer( | ||
SpyProductAbstract $productAbstractEntity, | ||
ProductAbstractTransfer $productAbstractTransfer | ||
): ProductAbstractTransfer { | ||
return $productAbstractTransfer->fromArray( | ||
$productAbstractEntity->toArray(), | ||
true, | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Pyz/Zed/ProductDetailWidget/Persistence/Mapper/ProductAbstractMapperInterface.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,37 @@ | ||
<?php | ||
|
||
namespace Pyz\Zed\ProductDetailPageWidget\Persistence\Mapper; | ||
|
||
use Generated\Shared\Transfer\ProductAbstractTransfer; | ||
use Generated\Shared\Transfer\ProductAbstractCollectionTransfer; | ||
use Orm\Zed\Product\Persistence\SpyProductAbstract; | ||
use Propel\Runtime\Collection\Collection; | ||
|
||
interface ProductAbstractMapperInterface | ||
{ | ||
/** | ||
* Maps a ProductAbstractTransfer to a SpyProductAbstract entity. | ||
* | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer | ||
* @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstractEntity | ||
* | ||
* @return \Orm\Zed\Product\Persistence\SpyProductAbstract | ||
*/ | ||
public function mapProductAbstractTransferToEntity( | ||
ProductAbstractTransfer $productAbstractTransfer, | ||
SpyProductAbstract $productAbstractEntity | ||
): SpyProductAbstract; | ||
|
||
/** | ||
* Maps a SpyProductAbstract entity to a ProductAbstractTransfer. | ||
* | ||
* @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstractEntity | ||
* @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\ProductAbstractTransfer | ||
*/ | ||
public function mapEntityToProductAbstractTransfer( | ||
SpyProductAbstract $productAbstractEntity, | ||
ProductAbstractTransfer $productAbstractTransfer | ||
): ProductAbstractTransfer; | ||
} |
Oops, something went wrong.