-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4142 from magento-mpi/PR-2019-4-29
MPI bug fix 2.2
- Loading branch information
Showing
13 changed files
with
222 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?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\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 LocalizedException | ||
*/ | ||
public function validateQuote(Quote $quote) | ||
{ | ||
$this->quoteValidator->validateBeforeSubmit($quote); | ||
} | ||
|
||
/** | ||
* Validates order. | ||
* | ||
* @param Order $order | ||
* @return void | ||
* @throws LocalizedException | ||
*/ | ||
public function validateOrder(Order $order) | ||
{ | ||
foreach ($order->getAddresses() as $address) { | ||
$errors = $this->orderAddressValidator->validate($address); | ||
if (!empty($errors)) { | ||
throw new LocalizedException( | ||
__("Failed address validation:\n%1", implode("\n", $errors)) | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.