![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/module-quote/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Quote\Model; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Validator\Exception as ValidatorException; use Magento\Sales\Model\Order; use Magento\Sales\Model\Order\Address\Validator as OrderAddressValidator; /** * Validates quote and order before quote submit. */ class SubmitQuoteValidator { /** * @var QuoteValidator */ private $quoteValidator; /** * @var OrderAddressValidator */ private $orderAddressValidator; /** * @param QuoteValidator $quoteValidator * @param OrderAddressValidator $orderAddressValidator */ public function __construct( QuoteValidator $quoteValidator, OrderAddressValidator $orderAddressValidator ) { $this->quoteValidator = $quoteValidator; $this->orderAddressValidator = $orderAddressValidator; } /** * Validates quote. * * @param Quote $quote * @return void * @throws ValidatorException * @throws LocalizedException */ public function validateQuote(Quote $quote): void { $this->quoteValidator->validateBeforeSubmit($quote); } /** * Validates order. * * @param Order $order * @return void * @throws ValidatorException * @throws LocalizedException */ public function validateOrder(Order $order): void { foreach ($order->getAddresses() as $address) { $errors = $this->orderAddressValidator->validate($address); if (!empty($errors)) { throw new ValidatorException( __("Failed address validation:\n%1", implode("\n", $errors)) ); } } } }