Skip to content

Commit

Permalink
Fix static tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Mar 25, 2019
1 parent 6b0ebf4 commit 59771c4
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions app/code/Magento/Quote/Model/QuoteManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,28 +532,7 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
);
$this->quoteRepository->save($quote);
} catch (\Exception $e) {
try {
if (!empty($this->addressesToSync)) {
foreach ($this->addressesToSync as $addressId) {
$this->addressRepository->deleteById($addressId);
}
}
$this->eventManager->dispatch(
'sales_model_service_quote_submit_failure',
[
'order' => $order,
'quote' => $quote,
'exception' => $e,
]
);
} catch (\Exception $consecutiveException) {
$message = sprintf(
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
$consecutiveException->getMessage()
);

throw new \Exception($message, 0, $e);
}
$this->rollbackAddresses($quote, $order, $e);
throw $e;
}
return $order;
Expand Down Expand Up @@ -620,4 +599,41 @@ protected function _prepareCustomerQuote($quote)
$shipping->setIsDefaultBilling(true);
}
}

/**
* Remove related to order and quote addresses and submit exception to further processing.
*
* @param Quote $quote
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param \Exception $e
* @throws \Exception
*/
private function rollbackAddresses(

This comment has been minimized.

Copy link
@drew7721

drew7721 Apr 7, 2020

Member

This should be a protected function. Extending this class is now a burden due to private methods such as this. As all (most) methods and proprieties in the class are protected so should this method be.

QuoteEntity $quote,
\Magento\Sales\Api\Data\OrderInterface $order,
\Exception $e
): void {
try {
if (!empty($this->addressesToSync)) {
foreach ($this->addressesToSync as $addressId) {
$this->addressRepository->deleteById($addressId);
}
}
$this->eventManager->dispatch(
'sales_model_service_quote_submit_failure',
[
'order' => $order,
'quote' => $quote,
'exception' => $e,
]
);
} catch (\Exception $consecutiveException) {
$message = sprintf(
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
$consecutiveException->getMessage()
);

throw new \Exception($message, 0, $e);
}
}
}

0 comments on commit 59771c4

Please sign in to comment.