Skip to content

Commit 1b0bccc

Browse files
author
Stanislav Idolov
authored
ENGCOM-1067: Checkout module: Removing deprecated Message Manager method calls #14343
2 parents 7979a48 + c3a6dcb commit 1b0bccc

File tree

18 files changed

+49
-44
lines changed

18 files changed

+49
-44
lines changed

app/code/Magento/Checkout/Block/Cart/ValidationMessages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function _prepareLayout()
8484
protected function validateMinimumAmount()
8585
{
8686
if (!$this->cartHelper->getQuote()->validateMinimumAmount()) {
87-
$this->messageManager->addNotice($this->getMinimumAmountErrorMessage()->getMessage());
87+
$this->messageManager->addNoticeMessage($this->getMinimumAmountErrorMessage()->getMessage());
8888
}
8989
}
9090

app/code/Magento/Checkout/Controller/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function _preDispatchValidateCustomer($redirect = true, $addErrors = t
7070
if (!$validationResult->isValid()) {
7171
if ($addErrors) {
7272
foreach ($validationResult->getMessages() as $error) {
73-
$this->messageManager->addError($error);
73+
$this->messageManager->addErrorMessage($error);
7474
}
7575
}
7676
if ($redirect) {

app/code/Magento/Checkout/Controller/Cart/Add.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ public function execute()
132132
}
133133
} catch (\Magento\Framework\Exception\LocalizedException $e) {
134134
if ($this->_checkoutSession->getUseNotice(true)) {
135-
$this->messageManager->addNotice(
135+
$this->messageManager->addNoticeMessage(
136136
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($e->getMessage())
137137
);
138138
} else {
139139
$messages = array_unique(explode("\n", $e->getMessage()));
140140
foreach ($messages as $message) {
141-
$this->messageManager->addError(
141+
$this->messageManager->addErrorMessage(
142142
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($message)
143143
);
144144
}
@@ -153,7 +153,10 @@ public function execute()
153153

154154
return $this->goBack($url);
155155
} catch (\Exception $e) {
156-
$this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.'));
156+
$this->messageManager->addExceptionMessage(
157+
$e,
158+
__('We can\'t add this item to your shopping cart right now.')
159+
);
157160
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
158161
return $this->goBack();
159162
}

app/code/Magento/Checkout/Controller/Cart/Addgroup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function execute()
6060
$this->addOrderItem($item);
6161
} catch (\Magento\Framework\Exception\LocalizedException $e) {
6262
if ($this->_checkoutSession->getUseNotice(true)) {
63-
$this->messageManager->addNotice($e->getMessage());
63+
$this->messageManager->addNoticeMessage($e->getMessage());
6464
} else {
65-
$this->messageManager->addError($e->getMessage());
65+
$this->messageManager->addErrorMessage($e->getMessage());
6666
}
6767
} catch (\Exception $e) {
68-
$this->messageManager->addException(
68+
$this->messageManager->addExceptionMessage(
6969
$e,
7070
__('We can\'t add this item to your shopping cart right now.')
7171
);

app/code/Magento/Checkout/Controller/Cart/Configure.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function execute()
6464

6565
try {
6666
if (!$quoteItem || $productId != $quoteItem->getProduct()->getId()) {
67-
$this->messageManager->addError(__("The quote item isn't found. Verify the item and try again."));
67+
$this->messageManager->addErrorMessage(
68+
__("The quote item isn't found. Verify the item and try again.")
69+
);
6870
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('checkout/cart');
6971
}
7072

@@ -83,7 +85,7 @@ public function execute()
8385
);
8486
return $resultPage;
8587
} catch (\Exception $e) {
86-
$this->messageManager->addError(__('We cannot configure the product.'));
88+
$this->messageManager->addErrorMessage(__('We cannot configure the product.'));
8789
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
8890
return $this->_goBack();
8991
}

app/code/Magento/Checkout/Controller/Cart/CouponPost.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ public function execute()
9595
if (!$itemsCount) {
9696
if ($isCodeLengthValid && $coupon->getId()) {
9797
$this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save();
98-
$this->messageManager->addSuccess(
98+
$this->messageManager->addSuccessMessage(
9999
__(
100100
'You used coupon code "%1".',
101101
$escaper->escapeHtml($couponCode)
102102
)
103103
);
104104
} else {
105-
$this->messageManager->addError(
105+
$this->messageManager->addErrorMessage(
106106
__(
107107
'The coupon code "%1" is not valid.',
108108
$escaper->escapeHtml($couponCode)
@@ -111,14 +111,14 @@ public function execute()
111111
}
112112
} else {
113113
if ($isCodeLengthValid && $coupon->getId() && $couponCode == $cartQuote->getCouponCode()) {
114-
$this->messageManager->addSuccess(
114+
$this->messageManager->addSuccessMessage(
115115
__(
116116
'You used coupon code "%1".',
117117
$escaper->escapeHtml($couponCode)
118118
)
119119
);
120120
} else {
121-
$this->messageManager->addError(
121+
$this->messageManager->addErrorMessage(
122122
__(
123123
'The coupon code "%1" is not valid.',
124124
$escaper->escapeHtml($couponCode)
@@ -127,12 +127,12 @@ public function execute()
127127
}
128128
}
129129
} else {
130-
$this->messageManager->addSuccess(__('You canceled the coupon code.'));
130+
$this->messageManager->addSuccessMessage(__('You canceled the coupon code.'));
131131
}
132132
} catch (\Magento\Framework\Exception\LocalizedException $e) {
133-
$this->messageManager->addError($e->getMessage());
133+
$this->messageManager->addErrorMessage($e->getMessage());
134134
} catch (\Exception $e) {
135-
$this->messageManager->addError(__('We cannot apply the coupon code.'));
135+
$this->messageManager->addErrorMessage(__('We cannot apply the coupon code.'));
136136
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
137137
}
138138

app/code/Magento/Checkout/Controller/Cart/Delete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function execute()
2424
try {
2525
$this->cart->removeItem($id)->save();
2626
} catch (\Exception $e) {
27-
$this->messageManager->addError(__('We can\'t remove the item.'));
27+
$this->messageManager->addErrorMessage(__('We can\'t remove the item.'));
2828
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
2929
}
3030
}

app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ public function execute()
6767
$this->_objectManager->get(\Magento\Framework\Escaper::class)
6868
->escapeHtml($item->getProduct()->getName())
6969
);
70-
$this->messageManager->addSuccess($message);
70+
$this->messageManager->addSuccessMessage($message);
7171
}
7272
return $this->_goBack($this->_url->getUrl('checkout/cart'));
7373
}
7474
} catch (\Magento\Framework\Exception\LocalizedException $e) {
7575
if ($this->_checkoutSession->getUseNotice(true)) {
76-
$this->messageManager->addNotice($e->getMessage());
76+
$this->messageManager->addNoticeMessage($e->getMessage());
7777
} else {
7878
$messages = array_unique(explode("\n", $e->getMessage()));
7979
foreach ($messages as $message) {
80-
$this->messageManager->addError($message);
80+
$this->messageManager->addErrorMessage($message);
8181
}
8282
}
8383

@@ -89,7 +89,7 @@ public function execute()
8989
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl($cartUrl));
9090
}
9191
} catch (\Exception $e) {
92-
$this->messageManager->addException($e, __('We can\'t update the item right now.'));
92+
$this->messageManager->addExceptionMessage($e, __('We can\'t update the item right now.'));
9393
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
9494
return $this->_goBack();
9595
}

app/code/Magento/Checkout/Controller/Cart/UpdatePost.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ protected function _emptyShoppingCart()
1818
try {
1919
$this->cart->truncate()->save();
2020
} catch (\Magento\Framework\Exception\LocalizedException $exception) {
21-
$this->messageManager->addError($exception->getMessage());
21+
$this->messageManager->addErrorMessage($exception->getMessage());
2222
} catch (\Exception $exception) {
23-
$this->messageManager->addException($exception, __('We can\'t update the shopping cart.'));
23+
$this->messageManager->addExceptionMessage($exception, __('We can\'t update the shopping cart.'));
2424
}
2525
}
2626

@@ -52,11 +52,11 @@ protected function _updateShoppingCart()
5252
$this->cart->updateItems($cartData)->save();
5353
}
5454
} catch (\Magento\Framework\Exception\LocalizedException $e) {
55-
$this->messageManager->addError(
55+
$this->messageManager->addErrorMessage(
5656
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($e->getMessage())
5757
);
5858
} catch (\Exception $e) {
59-
$this->messageManager->addException($e, __('We can\'t update the shopping cart.'));
59+
$this->messageManager->addExceptionMessage($e, __('We can\'t update the shopping cart.'));
6060
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
6161
}
6262
}

app/code/Magento/Checkout/Controller/Index/Index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function execute()
1818
/** @var \Magento\Checkout\Helper\Data $checkoutHelper */
1919
$checkoutHelper = $this->_objectManager->get(\Magento\Checkout\Helper\Data::class);
2020
if (!$checkoutHelper->canOnepageCheckout()) {
21-
$this->messageManager->addError(__('One-page checkout is turned off.'));
21+
$this->messageManager->addErrorMessage(__('One-page checkout is turned off.'));
2222
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
2323
}
2424

@@ -28,7 +28,7 @@ public function execute()
2828
}
2929

3030
if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) {
31-
$this->messageManager->addError(__('Guest checkout is disabled.'));
31+
$this->messageManager->addErrorMessage(__('Guest checkout is disabled.'));
3232
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
3333
}
3434

0 commit comments

Comments
 (0)