-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PBC-3241: TaxApp and OMS improvements to support 3rd-party providers.…
… (#10704) PBC-3241 `TaxApp` and `Oms` module improvements to support 3rd-party providers.
- Loading branch information
1 parent
a8b5a34
commit 4571b83
Showing
12 changed files
with
232 additions
and
2 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
56 changes: 56 additions & 0 deletions
56
src/Spryker/Zed/Oms/Business/Notifier/EventTriggeredNotifier.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,56 @@ | ||
<?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\Oms\Business\Notifier; | ||
|
||
use Generated\Shared\Transfer\OmsEventTriggeredTransfer; | ||
use Orm\Zed\Sales\Persistence\SpySalesOrder; | ||
use Orm\Zed\Sales\Persistence\SpySalesOrderItem; | ||
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; | ||
|
||
class EventTriggeredNotifier implements EventTriggeredNotifierInterface | ||
{ | ||
/** | ||
* @var array<\Spryker\Zed\OmsExtension\Dependency\Plugin\OmsEventTriggeredListenerPluginInterface> | ||
*/ | ||
protected array $omsEventTriggeredListenerPlugins; | ||
|
||
/** | ||
* @param array<\Spryker\Zed\OmsExtension\Dependency\Plugin\OmsEventTriggeredListenerPluginInterface> $omsEventTriggeredListenerPlugins | ||
*/ | ||
public function __construct(array $omsEventTriggeredListenerPlugins) | ||
{ | ||
$this->omsEventTriggeredListenerPlugins = $omsEventTriggeredListenerPlugins; | ||
} | ||
|
||
/** | ||
* @param string $idEvent | ||
* @param array<\Orm\Zed\Sales\Persistence\SpySalesOrderItem> $orderItems | ||
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity | ||
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data | ||
* | ||
* @return void | ||
*/ | ||
public function notifyOmsEventTriggeredListeners(string $idEvent, array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data): void | ||
{ | ||
$orderItemIds = array_map(function (SpySalesOrderItem $orderItem) { | ||
return $orderItem->getIdSalesOrderItem(); | ||
}, $orderItems); | ||
|
||
$omsEventTriggeredTransfer = (new OmsEventTriggeredTransfer()) | ||
->setIdEvent($idEvent) | ||
->setOrderItemIds($orderItemIds) | ||
->setIdSalesOrder($orderEntity->getIdSalesOrder()) | ||
->setEventData($data->getArrayCopy()); | ||
|
||
foreach ($this->omsEventTriggeredListenerPlugins as $omsEventTriggeredListener) { | ||
if ($omsEventTriggeredListener->isApplicable($omsEventTriggeredTransfer)) { | ||
$omsEventTriggeredListener->onEventTriggered($omsEventTriggeredTransfer); | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Spryker/Zed/Oms/Business/Notifier/EventTriggeredNotifierInterface.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 © 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\Oms\Business\Notifier; | ||
|
||
use Orm\Zed\Sales\Persistence\SpySalesOrder; | ||
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; | ||
|
||
interface EventTriggeredNotifierInterface | ||
{ | ||
/** | ||
* @param string $idEvent | ||
* @param array<\Orm\Zed\Sales\Persistence\SpySalesOrderItem> $orderItems | ||
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity | ||
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data | ||
* | ||
* @return void | ||
*/ | ||
public function notifyOmsEventTriggeredListeners(string $idEvent, array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data); | ||
} |
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
Oops, something went wrong.