Skip to content

[Forwardport] Replaced deprecated methods. #17737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function execute()
);
return $resultLayout;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
}
} else {
$this->messageManager->addError(__('Please correct the data sent.'));
$this->messageManager->addErrorMessage(__('Please correct the data sent.'));
}
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/App/Action/Plugin/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function _processNotLoggedInUser(\Magento\Framework\App\RequestInterfa
} else {
$this->_actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true);
$this->_response->setRedirect($this->_url->getCurrentUrl());
$this->messageManager->addError(__('Invalid Form Key. Please refresh the page.'));
$this->messageManager->addErrorMessage(__('Invalid Form Key. Please refresh the page.'));
$isRedirectNeeded = true;
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ protected function _performLogin(\Magento\Framework\App\RequestInterface $reques
$this->_auth->login($username, $password);
} catch (AuthenticationException $e) {
if (!$request->getParam('messageSent')) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$request->setParam('messageSent', true);
$outputValue = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Logout extends \Magento\Backend\Controller\Adminhtml\Auth
public function execute()
{
$this->_auth->logout();
$this->messageManager->addSuccess(__('You have logged out.'));
$this->messageManager->addSuccessMessage(__('You have logged out.'));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function execute()
try {
$this->_objectManager->create(\Magento\Catalog\Model\Product\Image::class)->clearCache();
$this->_eventManager->dispatch('clean_catalog_images_cache_after');
$this->messageManager->addSuccess(__('The image cache was cleaned.'));
$this->messageManager->addSuccessMessage(__('The image cache was cleaned.'));
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('An error occurred while clearing the image cache.'));
$this->messageManager->addExceptionMessage($e, __('An error occurred while clearing the image cache.'));
}

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ public function execute()
try {
$this->_objectManager->get(\Magento\Framework\View\Asset\MergeService::class)->cleanMergedJsCss();
$this->_eventManager->dispatch('clean_media_cache_after');
$this->messageManager->addSuccess(__('The JavaScript/CSS cache has been cleaned.'));
$this->messageManager->addSuccessMessage(__('The JavaScript/CSS cache has been cleaned.'));
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('An error occurred while clearing the JavaScript/CSS cache.'));
$this->messageManager
->addExceptionMessage($e, __('An error occurred while clearing the JavaScript/CSS cache.'));
}

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function execute()
{
$this->_objectManager->get(\Magento\Framework\App\State\CleanupFiles::class)->clearMaterializedViewFiles();
$this->_eventManager->dispatch('clean_static_files_cache_after');
$this->messageManager->addSuccess(__('The static files cache has been cleaned.'));
$this->messageManager->addSuccessMessage(__('The static files cache has been cleaned.'));

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute()
foreach ($this->_cacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
$this->messageManager->addSuccess(__("You flushed the cache storage."));
$this->messageManager->addSuccessMessage(__("You flushed the cache storage."));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('adminhtml/*');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute()
$cacheFrontend->clean();
}
$this->_eventManager->dispatch('adminhtml_cache_flush_system');
$this->messageManager->addSuccess(__("The Magento cache storage has been flushed."));
$this->messageManager->addSuccessMessage(__("The Magento cache storage has been flushed."));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('adminhtml/*');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ private function disableCache()
}
if ($updatedTypes > 0) {
$this->_cacheState->persist();
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
$this->messageManager->addSuccessMessage(__("%1 cache type(s) disabled.", $updatedTypes));
}
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('An error occurred while disabling cache.'));
$this->messageManager->addExceptionMessage($e, __('An error occurred while disabling cache.'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ private function enableCache()
}
if ($updatedTypes > 0) {
$this->_cacheState->persist();
$this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes));
$this->messageManager->addSuccessMessage(__("%1 cache type(s) enabled.", $updatedTypes));
}
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('An error occurred while enabling cache.'));
$this->messageManager->addExceptionMessage($e, __('An error occurred while enabling cache.'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function execute()
$updatedTypes++;
}
if ($updatedTypes > 0) {
$this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
$this->messageManager->addSuccessMessage(__("%1 cache type(s) refreshed.", $updatedTypes));
}
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('An error occurred while refreshing cache.'));
$this->messageManager->addExceptionMessage($e, __('An error occurred while refreshing cache.'));
}

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function execute()
foreach ($collectionsNames as $collectionName) {
$this->_objectManager->create($collectionName)->aggregate();
}
$this->messageManager->addSuccess(__('We updated lifetime statistic.'));
$this->messageManager->addSuccessMessage(__('We updated lifetime statistic.'));
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t refresh lifetime statistics.'));
$this->messageManager->addErrorMessage(__('We can\'t refresh lifetime statistics.'));
$this->logger->critical($e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public function execute()
$errors = $user->validate();
if ($errors !== true && !empty($errors)) {
foreach ($errors as $error) {
$this->messageManager->addError($error);
$this->messageManager->addErrorMessage($error);
}
} else {
$user->save();
$user->sendNotificationEmailsIfRequired();
$this->messageManager->addSuccess(__('You saved the account.'));
$this->messageManager->addSuccessMessage(__('You saved the account.'));
}
} catch (UserLockedException $e) {
$this->_auth->logout();
Expand All @@ -91,12 +91,12 @@ public function execute()
} catch (ValidatorException $e) {
$this->messageManager->addMessages($e->getMessages());
if ($e->getMessage()) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
}
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('An error occurred while saving account.'));
$this->messageManager->addErrorMessage(__('An error occurred while saving account.'));
}

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public function execute()

try {
$design->delete();
$this->messageManager->addSuccess(__('You deleted the design change.'));
$this->messageManager->addSuccessMessage(__('You deleted the design change.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __("You can't delete the design change."));
$this->messageManager->addExceptionMessage($e, __("You can't delete the design change."));
}
}
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function execute()
try {
$design->save();
$this->_eventManager->dispatch('theme_save_after');
$this->messageManager->addSuccess(__('You saved the design change.'));
$this->messageManager->addSuccessMessage(__('You saved the design change.'));
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$this->_objectManager->get(\Magento\Backend\Model\Session::class)->setDesignData($data);
return $resultRedirect->setPath('adminhtml/*/', ['id' => $design->getId()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ protected function _backupDatabase()
->setType('db')
->setPath($filesystem->getDirectoryRead(DirectoryList::VAR_DIR)->getAbsolutePath('backups'));
$backupDb->createBackup($backup);
$this->messageManager->addSuccess(__('The database was backed up.'));
$this->messageManager->addSuccessMessage(__('The database was backed up.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
return false;
} catch (\Exception $e) {
$this->messageManager->addException(
$this->messageManager->addExceptionMessage(
$e,
__('We can\'t create a backup right now. Please try again later.')
);
Expand All @@ -125,7 +125,7 @@ protected function _backupDatabase()
*/
protected function _addDeletionNotice($typeTitle)
{
$this->messageManager->addNotice(
$this->messageManager->addNoticeMessage(
__(
'Deleting a %1 will not delete the information associated with the %1 (e.g. categories, products, etc.)'
. ', but the %1 will not be able to be restored. It is suggested that you create a database backup '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function execute()
{
$itemId = $this->getRequest()->getParam('item_id', null);
if (!($model = $this->_objectManager->create(\Magento\Store\Model\Group::class)->load($itemId))) {
$this->messageManager->addError(__('Something went wrong. Please try again.'));
$this->messageManager->addErrorMessage(__('Something went wrong. Please try again.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
return $redirectResult->setPath('adminhtml/*/');
}
if (!$model->isCanDelete()) {
$this->messageManager->addError(__('This store cannot be deleted.'));
$this->messageManager->addErrorMessage(__('This store cannot be deleted.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $itemId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function execute()
$redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

if (!($model = $this->_objectManager->create(\Magento\Store\Model\Group::class)->load($itemId))) {
$this->messageManager->addError(__('Something went wrong. Please try again.'));
$this->messageManager->addErrorMessage(__('Something went wrong. Please try again.'));
return $redirectResult->setPath('adminhtml/*/');
}
if (!$model->isCanDelete()) {
$this->messageManager->addError(__('This store cannot be deleted.'));
$this->messageManager->addErrorMessage(__('This store cannot be deleted.'));
return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $model->getId()]);
}

Expand All @@ -35,12 +35,12 @@ public function execute()

try {
$model->delete();
$this->messageManager->addSuccess(__('You deleted the store.'));
$this->messageManager->addSuccessMessage(__('You deleted the store.'));
return $redirectResult->setPath('adminhtml/*/');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Unable to delete the store. Please try again later.'));
$this->messageManager->addExceptionMessage($e, __('Unable to delete the store. Please try again later.'));
}
return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $itemId]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function execute()
{
$itemId = $this->getRequest()->getParam('item_id', null);
if (!($model = $this->_objectManager->create(\Magento\Store\Model\Store::class)->load($itemId))) {
$this->messageManager->addError(__('Something went wrong. Please try again.'));
$this->messageManager->addErrorMessage(__('Something went wrong. Please try again.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
return $redirectResult->setPath('adminhtml/*/');
}
if (!$model->isCanDelete()) {
$this->messageManager->addError(__('This store view cannot be deleted.'));
$this->messageManager->addErrorMessage(__('This store view cannot be deleted.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $itemId]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function execute()
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
if (!($model = $this->_objectManager->create(\Magento\Store\Model\Store::class)->load($itemId))) {
$this->messageManager->addError(__('Something went wrong. Please try again.'));
$this->messageManager->addErrorMessage(__('Something went wrong. Please try again.'));
return $redirectResult->setPath('adminhtml/*/');
}
if (!$model->isCanDelete()) {
$this->messageManager->addError(__('This store view cannot be deleted.'));
$this->messageManager->addErrorMessage(__('This store view cannot be deleted.'));
return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $model->getId()]);
}

Expand All @@ -37,12 +37,13 @@ public function execute()
try {
$model->delete();

$this->messageManager->addSuccess(__('You deleted the store view.'));
$this->messageManager->addSuccessMessage(__('You deleted the store view.'));
return $redirectResult->setPath('adminhtml/*/');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Unable to delete the store view. Please try again later.'));
$this->messageManager
->addExceptionMessage($e, __('Unable to delete the store view. Please try again later.'));
}
return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $itemId]);
}
Expand Down
Loading