* @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\Order\Repository; use Order; use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; use PrestaShop\PrestaShop\Core\Exception\CoreException; use PrestaShop\PrestaShop\Core\Repository\AbstractObjectModelRepository; use PrestaShopException; class OrderRepository extends AbstractObjectModelRepository { /** * Gets legacy Order * * @param OrderId $orderId * * @return Order * * @throws OrderException * @throws CoreException */ public function get(OrderId $orderId): Order { try { $order = new Order($orderId->getValue()); if ($order->id !== $orderId->getValue()) { throw new OrderNotFoundException($orderId, sprintf('%s #%d was not found', Order::class, $orderId->getValue())); } } catch (PrestaShopException $e) { throw new CoreException( sprintf( 'Error occurred when trying to get %s #%d [%s]', Order::class, $orderId->getValue(), $e->getMessage() ), 0, $e ); } return $order; } }