* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PrestashopCheckout\Order\Matrice\CommandHandler; use PrestaShop\Module\PrestashopCheckout\Event\EventDispatcherInterface; use PrestaShop\Module\PrestashopCheckout\Order\Matrice\Command\UpdateOrderMatriceCommand; use PrestaShop\Module\PrestashopCheckout\Order\Matrice\Event\OrderMatriceUpdatedEvent; class UpdateOrderMatriceCommandHandler { private $eventDispatcher; public function __construct(EventDispatcherInterface $eventDispatcher) { $this->eventDispatcher = $eventDispatcher; } /** * @throws \PrestaShopException * @throws \PrestaShopDatabaseException */ public function handle(UpdateOrderMatriceCommand $command) { $orderMatrice = new \OrderMatrice(); $orderMatrice->id_order_prestashop = $command->getOrderId()->getValue(); $orderMatrice->id_order_paypal = $command->getOrderPayPalId()->getValue(); $res = $orderMatrice->add(); if (!empty($res)) { $this->eventDispatcher->dispatch(new OrderMatriceUpdatedEvent()); } } }