* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\OrderState\QueryHandler; use OrderState; use PrestaShop\PrestaShop\Core\Domain\OrderState\Exception\OrderStateNotFoundException; use PrestaShop\PrestaShop\Core\Domain\OrderState\Query\GetOrderStateForEditing; use PrestaShop\PrestaShop\Core\Domain\OrderState\QueryHandler\GetOrderStateForEditingHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\OrderState\QueryResult\EditableOrderState; /** * Handles command that gets orderState for editing * * @internal */ final class GetOrderStateForEditingHandler implements GetOrderStateForEditingHandlerInterface { /** * {@inheritdoc} */ public function handle(GetOrderStateForEditing $query) { $orderStateId = $query->getOrderStateId(); $orderState = new OrderState($orderStateId->getValue()); if ($orderState->id !== $orderStateId->getValue()) { throw new OrderStateNotFoundException($orderStateId, sprintf('OrderState with id "%s" was not found', $orderStateId->getValue())); } return new EditableOrderState( $orderStateId, $orderState->name, $orderState->color, (bool) $orderState->logable, (bool) $orderState->invoice, (bool) $orderState->hidden, (bool) $orderState->send_email, (bool) $orderState->pdf_invoice, (bool) $orderState->pdf_delivery, (bool) $orderState->shipped, (bool) $orderState->paid, (bool) $orderState->delivery, $orderState->template, (bool) $orderState->deleted ); } }