Skip to content

Commit b4a822c

Browse files
ENGCOM-6168: Fixed deprecated method usages of MessageManager #25281
- Merge Pull Request #25281 from drpayyne/magento2:codefix/wishlist-01 - Merged commits: 1. c11c476 2. 139214e
2 parents 65763df + 139214e commit b4a822c

File tree

17 files changed

+78
-53
lines changed

17 files changed

+78
-53
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<element name="FolderName" type="button" selector="input[data-role='promptField']" />
158158
<element name="AcceptFolderName" type="button" selector=".action-primary.action-accept" timeout="30"/>
159159
<element name="StorageRootArrow" type="button" selector="#root > .jstree-icon" />
160+
<element name="FolderContainer" type="button" selector="div[data-role='tree']" />
160161
<element name="checkIfArrowExpand" type="button" selector="//li[@id='root' and contains(@class,'jstree-closed')]" />
161162
<element name="WysiwygArrow" type="button" selector="#d3lzaXd5Zw-- > .jstree-icon" />
162163
<element name="checkIfWysiwygArrowExpand" type="button" selector="//li[@id='d3lzaXd5Zw--' and contains(@class,'jstree-closed')]" />

app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@
7070
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="scrollToTinyMCE4" />
7171
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon2" />
7272
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
73+
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
7374
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CancelBtn}}" stepKey="waitForCancelButton2"/>
7475
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CancelBtn}}" userInput="Cancel" stepKey="seeCancelBtn2" />
75-
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
76+
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CreateFolder}}" stepKey="waitForCreateFolderBtn2"/>
7677
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CreateFolder}}" userInput="Create Folder" stepKey="seeCreateFolderBtn2" />
77-
<waitForLoadingMaskToDisappear stepKey="waitForLoading14"/>
78+
<see selector="{{ProductDescriptionWYSIWYGToolbarSection.FolderContainer}}" userInput="Storage Root" stepKey="seeFolderContainer" />
7879
<click userInput="Storage Root" stepKey="clickOnRootFolder" />
7980
<waitForLoadingMaskToDisappear stepKey="waitForLoading15"/>
8081
<dontSeeElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn3" />

app/code/Magento/Wishlist/Controller/Index/Cart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function execute()
186186
'You added %1 to your shopping cart.',
187187
$this->escaper->escapeHtml($item->getProduct()->getName())
188188
);
189-
$this->messageManager->addSuccess($message);
189+
$this->messageManager->addSuccessMessage($message);
190190
}
191191

192192
if ($this->cartHelper->getShouldRedirectToCart()) {
@@ -214,7 +214,7 @@ public function execute()
214214
$resultJson->setData(['backUrl' => $redirectUrl]);
215215
return $resultJson;
216216
}
217-
217+
218218
$resultRedirect->setUrl($redirectUrl);
219219
return $resultRedirect;
220220
}

app/code/Magento/Wishlist/Controller/Index/Configure.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
use Magento\Framework\Controller\ResultFactory;
1212

1313
/**
14+
* Wishlist Configure Controller
15+
*
1416
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1517
*/
16-
class Configure extends \Magento\Wishlist\Controller\AbstractIndex
18+
class Configure extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpGetActionInterface
1719
{
1820
/**
1921
* Core registry
@@ -102,11 +104,11 @@ public function execute()
102104

103105
return $resultPage;
104106
} catch (\Magento\Framework\Exception\LocalizedException $e) {
105-
$this->messageManager->addError($e->getMessage());
107+
$this->messageManager->addErrorMessage($e->getMessage());
106108
$resultRedirect->setPath('*');
107109
return $resultRedirect;
108110
} catch (\Exception $e) {
109-
$this->messageManager->addError(__('We can\'t configure the product right now.'));
111+
$this->messageManager->addErrorMessage(__('We can\'t configure the product right now.'));
110112
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
111113
$resultRedirect->setPath('*');
112114
return $resultRedirect;

app/code/Magento/Wishlist/Controller/Index/Remove.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
use Magento\Wishlist\Model\Product\AttributeValueProvider;
1515

1616
/**
17+
* Wishlist Remove Controller
18+
*
1719
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1820
*/
19-
class Remove extends \Magento\Wishlist\Controller\AbstractIndex
21+
class Remove extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpPostActionInterface
2022
{
2123
/**
2224
* @var WishlistProviderInterface
@@ -88,11 +90,11 @@ public function execute()
8890
]
8991
);
9092
} catch (\Magento\Framework\Exception\LocalizedException $e) {
91-
$this->messageManager->addError(
93+
$this->messageManager->addErrorMessage(
9294
__('We can\'t delete the item from Wish List right now because of an error: %1.', $e->getMessage())
9395
);
9496
} catch (\Exception $e) {
95-
$this->messageManager->addError(__('We can\'t delete the item from the Wish List right now.'));
97+
$this->messageManager->addErrorMessage(__('We can\'t delete the item from the Wish List right now.'));
9698
}
9799

98100
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();

app/code/Magento/Wishlist/Controller/Index/Send.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function execute()
219219
}
220220

221221
if ($error) {
222-
$this->messageManager->addError($error);
222+
$this->messageManager->addErrorMessage($error);
223223
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
224224
$resultRedirect->setPath('*/*/share');
225225
return $resultRedirect;
@@ -285,12 +285,12 @@ public function execute()
285285
$this->inlineTranslation->resume();
286286

287287
$this->_eventManager->dispatch('wishlist_share', ['wishlist' => $wishlist]);
288-
$this->messageManager->addSuccess(__('Your wish list has been shared.'));
288+
$this->messageManager->addSuccessMessage(__('Your wish list has been shared.'));
289289
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);
290290
return $resultRedirect;
291291
} catch (\Exception $e) {
292292
$this->inlineTranslation->resume();
293-
$this->messageManager->addError($e->getMessage());
293+
$this->messageManager->addErrorMessage($e->getMessage());
294294
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
295295
$resultRedirect->setPath('*/*/share');
296296
return $resultRedirect;

app/code/Magento/Wishlist/Controller/Index/Update.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function execute()
103103
$item->delete();
104104
} catch (\Exception $e) {
105105
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
106-
$this->messageManager->addError(__('We can\'t delete item from Wish List right now.'));
106+
$this->messageManager->addErrorMessage(__('We can\'t delete item from Wish List right now.'));
107107
}
108108
}
109109

@@ -118,7 +118,7 @@ public function execute()
118118
);
119119
$updatedItems++;
120120
} catch (\Exception $e) {
121-
$this->messageManager->addError(
121+
$this->messageManager->addErrorMessage(
122122
__(
123123
'Can\'t save description %1',
124124
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($description)
@@ -133,7 +133,7 @@ public function execute()
133133
$wishlist->save();
134134
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
135135
} catch (\Exception $e) {
136-
$this->messageManager->addError(__('Can\'t update wish list'));
136+
$this->messageManager->addErrorMessage(__('Can\'t update wish list'));
137137
}
138138
}
139139

app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
use Magento\Wishlist\Controller\WishlistProviderInterface;
1515

1616
/**
17+
* Wishlist UpdateItemOptions Controller
18+
*
1719
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1820
*/
19-
class UpdateItemOptions extends \Magento\Wishlist\Controller\AbstractIndex
21+
class UpdateItemOptions extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpPostActionInterface
2022
{
2123
/**
2224
* @var WishlistProviderInterface
@@ -85,7 +87,7 @@ public function execute()
8587
}
8688

8789
if (!$product || !$product->isVisibleInCatalog()) {
88-
$this->messageManager->addError(__('We can\'t specify a product.'));
90+
$this->messageManager->addErrorMessage(__('We can\'t specify a product.'));
8991
$resultRedirect->setPath('*/');
9092
return $resultRedirect;
9193
}
@@ -114,11 +116,11 @@ public function execute()
114116
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
115117

116118
$message = __('%1 has been updated in your Wish List.', $product->getName());
117-
$this->messageManager->addSuccess($message);
119+
$this->messageManager->addSuccessMessage($message);
118120
} catch (\Magento\Framework\Exception\LocalizedException $e) {
119-
$this->messageManager->addError($e->getMessage());
121+
$this->messageManager->addErrorMessage($e->getMessage());
120122
} catch (\Exception $e) {
121-
$this->messageManager->addError(__('We can\'t update your Wish List right now.'));
123+
$this->messageManager->addErrorMessage(__('We can\'t update your Wish List right now.'));
122124
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
123125
}
124126
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);

app/code/Magento/Wishlist/Controller/Shared/Cart.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Checkout\Helper\Cart as CartHelper;
1010
use Magento\Checkout\Model\Cart as CustomerCart;
1111
use Magento\Framework\App\Action\Context as ActionContext;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
1213
use Magento\Framework\Controller\ResultFactory;
1314
use Magento\Framework\Escaper;
1415
use Magento\Framework\Exception\LocalizedException;
@@ -18,9 +19,11 @@
1819
use Magento\Wishlist\Model\ResourceModel\Item\Option\Collection as OptionCollection;
1920

2021
/**
22+
* Wishlist Cart Controller
23+
*
2124
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2225
*/
23-
class Cart extends \Magento\Framework\App\Action\Action
26+
class Cart extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface
2427
{
2528
/**
2629
* @var CustomerCart
@@ -103,19 +106,19 @@ public function execute()
103106
'You added %1 to your shopping cart.',
104107
$this->escaper->escapeHtml($item->getProduct()->getName())
105108
);
106-
$this->messageManager->addSuccess($message);
109+
$this->messageManager->addSuccessMessage($message);
107110
}
108111

109112
if ($this->cartHelper->getShouldRedirectToCart()) {
110113
$redirectUrl = $this->cartHelper->getCartUrl();
111114
}
112115
} catch (ProductException $e) {
113-
$this->messageManager->addError(__('This product(s) is out of stock.'));
116+
$this->messageManager->addErrorMessage(__('This product(s) is out of stock.'));
114117
} catch (LocalizedException $e) {
115-
$this->messageManager->addNotice($e->getMessage());
118+
$this->messageManager->addNoticeMessage($e->getMessage());
116119
$redirectUrl = $item->getProductUrl();
117120
} catch (\Exception $e) {
118-
$this->messageManager->addException($e, __('We can\'t add the item to the cart right now.'));
121+
$this->messageManager->addExceptionMessage($e, __('We can\'t add the item to the cart right now.'));
119122
}
120123
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
121124
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

app/code/Magento/Wishlist/Controller/WishlistProvider.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Wishlist\Controller;
87

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Framework\App\RequestInterface;
1010

11+
/**
12+
* WishlistProvider Controller
13+
*
14+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
15+
*/
1116
class WishlistProvider implements WishlistProviderInterface
1217
{
1318
/**
@@ -54,7 +59,8 @@ public function __construct(
5459
}
5560

5661
/**
57-
* {@inheritdoc}
62+
* @inheritdoc
63+
*
5864
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5965
*/
6066
public function getWishlist($wishlistId = null)
@@ -85,10 +91,10 @@ public function getWishlist($wishlistId = null)
8591
);
8692
}
8793
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
88-
$this->messageManager->addError($e->getMessage());
94+
$this->messageManager->addErrorMessage($e->getMessage());
8995
return false;
9096
} catch (\Exception $e) {
91-
$this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
97+
$this->messageManager->addExceptionMessage($e, __('We can\'t create the Wish List right now.'));
9298
return false;
9399
}
94100
$this->wishlist = $wishlist;

0 commit comments

Comments
 (0)