diff --git a/vendor/magento/module-quote/Model/QuoteValidator.php b/vendor/magento/module-quote/Model/QuoteValidator.php index 87d010dee9524..d4ec70adc006f 100644 --- a/vendor/magento/module-quote/Model/QuoteValidator.php +++ b/vendor/magento/module-quote/Model/QuoteValidator.php @@ -14,7 +14,6 @@ use Magento\Quote\Model\Quote as QuoteEntity; use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage as OrderAmountValidationMessage; use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface; -use Magento\Framework\Webapi\Rest\Response as RestResponse; /** * Class to validate the quote @@ -44,24 +43,17 @@ class QuoteValidator */ private $quoteValidationRule; - /** - * @var RestResponse - */ - private $_response; - /** * QuoteValidator constructor. * * @param AllowedCountries|null $allowedCountryReader * @param OrderAmountValidationMessage|null $minimumAmountMessage * @param QuoteValidationRuleInterface|null $quoteValidationRule - * @param RestResponse|null $response */ public function __construct( AllowedCountries $allowedCountryReader = null, OrderAmountValidationMessage $minimumAmountMessage = null, - QuoteValidationRuleInterface $quoteValidationRule = null, - RestResponse $response = null + QuoteValidationRuleInterface $quoteValidationRule = null ) { $this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance() ->get(AllowedCountries::class); @@ -69,7 +61,6 @@ public function __construct( ->get(OrderAmountValidationMessage::class); $this->quoteValidationRule = $quoteValidationRule ?: ObjectManager::getInstance() ->get(QuoteValidationRuleInterface::class); - $this->_response = $response ?: ObjectManager::getInstance()->get(RestResponse::class); } /** @@ -115,7 +106,6 @@ public function validateBeforeSubmit(QuoteEntity $quote) $defaultMessage .= ' %1'; } if ($defaultMessage) { - $this->_response->setHeader('errorRedirectAction', '#shipping'); throw new ValidatorException(__($defaultMessage, implode(' ', $messages))); } } diff --git a/vendor/magento/module-quote/Plugin/Webapi/Model/ErrorRedirectProcessor.php b/vendor/magento/module-quote/Plugin/Webapi/Model/ErrorRedirectProcessor.php new file mode 100644 index 0000000000000..321919a1c5eb0 --- /dev/null +++ b/vendor/magento/module-quote/Plugin/Webapi/Model/ErrorRedirectProcessor.php @@ -0,0 +1,43 @@ +restResponse->setHeader('errorRedirectAction', '#shipping'); + throw $e; + } + + return $result; + } +} diff --git a/vendor/magento/module-quote/etc/webapi_rest/di.xml b/vendor/magento/module-quote/etc/webapi_rest/di.xml index a3f481bd49463..3a9c73292ac37 100644 --- a/vendor/magento/module-quote/etc/webapi_rest/di.xml +++ b/vendor/magento/module-quote/etc/webapi_rest/di.xml @@ -23,4 +23,7 @@ + + +