Skip to content
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
10 changes: 6 additions & 4 deletions app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ public function execute()
/** @var \Magento\Search\Model\SynonymGroup $synGroupModel */
$synGroupModel = $this->synGroupRepository->get($id);
$this->synGroupRepository->delete($synGroupModel);
$this->messageManager->addSuccess(__('The synonym group has been deleted.'));
$this->messageManager->addSuccessMessage(__('The synonym group has been deleted.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$this->logger->error($e);
} catch (\Exception $e) {
$this->messageManager->addError(__('An error was encountered while performing delete operation.'));
$this->messageManager->addErrorMessage(
__('An error was encountered while performing delete operation.')
);
$this->logger->error($e);
}
} else {
$this->messageManager->addError(__('We can\'t find a synonym group to delete.'));
$this->messageManager->addErrorMessage(__('We can\'t find a synonym group to delete.'));
}

return $resultRedirect->setPath('*/*/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function execute()

// 2. Initial checking
if ($groupId && (!$synGroup->getGroupId())) {
$this->messageManager->addError(__('This synonyms group no longer exists.'));
$this->messageManager->addErrorMessage(__('This synonyms group no longer exists.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ public function execute()
$this->synGroupRepository->delete($synonymGroup);
$deletedItems++;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
}
}
if ($deletedItems != 0) {
if ($collectionSize != $deletedItems) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
__('Failed to delete %1 synonym group(s).', $collectionSize - $deletedItems)
);
}

$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('A total of %1 synonym group(s) have been deleted.', $deletedItems)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function execute()
$synGroup = $this->synGroupRepository->get($synGroupId);

if (!$synGroup->getGroupId() && $synGroupId) {
$this->messageManager->addError(__('This synonym group no longer exists.'));
$this->messageManager->addErrorMessage(__('This synonym group no longer exists.'));
return $resultRedirect->setPath('*/*/');
}

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public function execute()
$model = $this->_objectManager->create(\Magento\Search\Model\Query::class);
$model->setId($id);
$model->delete();
$this->messageManager->addSuccess(__('You deleted the search.'));
$this->messageManager->addSuccessMessage(__('You deleted the search.'));
$resultRedirect->setPath('search/*/');
return $resultRedirect;
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$resultRedirect->setPath('search/*/edit', ['id' => $this->getRequest()->getParam('id')]);
return $resultRedirect;
}
}
$this->messageManager->addError(__('We can\'t find a search term to delete.'));
$this->messageManager->addErrorMessage(__('We can\'t find a search term to delete.'));
$resultRedirect->setPath('search/*/');
return $resultRedirect;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function execute()
if ($id) {
$model->load($id);
if (!$model->getId()) {
$this->messageManager->addError(__('This search no longer exists.'));
$this->messageManager->addErrorMessage(__('This search no longer exists.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('search/*');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public function execute()
{
$searchIds = $this->getRequest()->getParam('search');
if (!is_array($searchIds)) {
$this->messageManager->addError(__('Please select searches.'));
$this->messageManager->addErrorMessage(__('Please select searches.'));
} else {
try {
foreach ($searchIds as $searchId) {
$model = $this->_objectManager->create(\Magento\Search\Model\Query::class)->load($searchId);
$model->delete();
}
$this->messageManager->addSuccess(__('Total of %1 record(s) were deleted.', count($searchIds)));
$this->messageManager->addSuccessMessage(__('Total of %1 record(s) were deleted.', count($searchIds)));
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
}
}
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
Expand Down
9 changes: 6 additions & 3 deletions app/code/Magento/Search/Controller/Adminhtml/Term/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ public function execute()
$model->addData($data);
$model->setIsProcessed(0);
$model->save();
$this->messageManager->addSuccess(__('You saved the search term.'));
$this->messageManager->addSuccessMessage(__('You saved the search term.'));
} catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
return $this->proceedToEdit($data);
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while saving the search query.'));
$this->messageManager->addExceptionMessage(
$e,
__('Something went wrong while saving the search query.')
);
return $this->proceedToEdit($data);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public function testDeleteAction()
$this->repository->expects($this->once())->method('get')->with(10)->willReturn($this->synonymGroupMock);

$this->messageManagerMock->expects($this->once())
->method('addSuccess')
->method('addSuccessMessage')
->with(__('The synonym group has been deleted.'));

$this->messageManagerMock->expects($this->never())->method('addError');
$this->messageManagerMock->expects($this->never())->method('addErrorMessage');

$this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();

Expand All @@ -124,10 +124,10 @@ public function testDeleteActionNoId()
->willReturn(null);

$this->messageManagerMock->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with(__('We can\'t find a synonym group to delete.'));
$this->messageManagerMock->expects($this->never())
->method('addSuccess');
->method('addSuccessMessage');

$this->resultRedirectMock->expects($this->once())
->method('setPath')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function setUp()
->getMockForAbstractClass();
$this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['addSuccess', 'addError'])
->setMethods(['addSuccessMessage', 'addErrorMessage'])
->getMockForAbstractClass();
$this->pageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
->setMethods([])
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testExecute()
$this->createQuery(0, 1);
$this->createQuery(1, 2);
$this->messageManager->expects($this->once())
->method('addSuccess')
->method('addSuccessMessage')
->will($this->returnSelf());
$this->resultRedirectMock->expects($this->once())
->method('setPath')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function setUp()

$this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['addSuccess', 'addError', 'addException'])
->setMethods(['addSuccessMessage', 'addErrorMessage', 'addExceptionMessage'])
->getMockForAbstractClass();
$this->context->expects($this->any())
->method('getMessageManager')
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testExecuteLoadQueryQueryId()
$this->query->expects($this->once())->method('getId')->willReturn(false);
$this->query->expects($this->once())->method('load')->with($queryId);

$this->messageManager->expects($this->once())->method('addSuccess');
$this->messageManager->expects($this->once())->method('addSuccessMessage');

$this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
$this->assertSame($this->redirect, $this->controller->execute());
Expand All @@ -161,7 +161,7 @@ public function testExecuteLoadQueryQueryIdQueryText()
$this->query->expects($this->once())->method('loadByQueryText')->with($queryText);
$this->query->expects($this->any())->method('getId')->willReturn($queryId);

$this->messageManager->expects($this->once())->method('addSuccess');
$this->messageManager->expects($this->once())->method('addSuccessMessage');

$this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
$this->assertSame($this->redirect, $this->controller->execute());
Expand All @@ -180,7 +180,7 @@ public function testExecuteLoadQueryQueryIdQueryText2()
$this->query->expects($this->any())->method('getId')->willReturn(false);
$this->query->expects($this->once())->method('load')->with($queryId);

$this->messageManager->expects($this->once())->method('addSuccess');
$this->messageManager->expects($this->once())->method('addSuccessMessage');

$this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
$this->assertSame($this->redirect, $this->controller->execute());
Expand All @@ -199,7 +199,7 @@ public function testExecuteLoadQueryQueryIdQueryTextException()
$this->query->expects($this->once())->method('loadByQueryText')->with($queryText);
$this->query->expects($this->any())->method('getId')->willReturn($anotherQueryId);

$this->messageManager->expects($this->once())->method('addError');
$this->messageManager->expects($this->once())->method('addErrorMessage');
$this->session->expects($this->once())->method('setPageData');
$this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
$this->assertSame($this->redirect, $this->controller->execute());
Expand All @@ -216,7 +216,7 @@ public function testExecuteException()
$this->query->expects($this->once())->method('setStoreId');
$this->query->expects($this->once())->method('loadByQueryText')->willThrowException(new \Exception());

$this->messageManager->expects($this->once())->method('addException');
$this->messageManager->expects($this->once())->method('addExceptionMessage');
$this->session->expects($this->once())->method('setPageData');
$this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
$this->assertSame($this->redirect, $this->controller->execute());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public function execute()
{
try {
$this->sessionsManager->logoutOtherUserSessions();
$this->messageManager->addSuccess(__('All other open sessions for this account were terminated.'));
$this->messageManager->addSuccessMessage(__('All other open sessions for this account were terminated.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __("We couldn't logout because of an error."));
$this->messageManager->addExceptionMessage($e, __("We couldn't logout because of an error."));
}
$this->_redirect('*/*/activity');
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Security/Model/Plugin/AuthSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function addUserLogoutNotification()
$this->sessionsManager->getCurrentSession()->getStatus()
);
} elseif ($message = $this->sessionsManager->getLogoutReasonMessage()) {
$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Security/Model/Plugin/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function beforeExecute(Login $login)
{
$logoutReasonCode = $this->securityCookie->getLogoutReasonCookie();
if ($this->isLoginForm($login) && $logoutReasonCode >= 0) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
$this->sessionsManager->getLogoutReasonMessageByStatus($logoutReasonCode)
);
$this->securityCookie->deleteLogoutReasonCookie();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function setUp()

$this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['addSuccess', 'addError', 'addException'])
->setMethods(['addSuccessMessage', 'addErrorMessage', 'addExceptionMessage'])
->getMockForAbstractClass();
$this->contextMock->expects($this->any())
->method('getMessageManager')
Expand Down Expand Up @@ -132,12 +132,12 @@ public function testExecute()
$this->sessionsManager->expects($this->once())
->method('logoutOtherUserSessions');
$this->messageManager->expects($this->once())
->method('addSuccess')
->method('addSuccessMessage')
->with($successMessage);
$this->messageManager->expects($this->never())
->method('addError');
->method('addErrorMessage');
$this->messageManager->expects($this->never())
->method('addException');
->method('addExceptionMessage');
$this->responseMock->expects($this->once())
->method('setRedirect');
$this->actionFlagMock->expects($this->once())
Expand All @@ -158,7 +158,7 @@ public function testExecuteLocalizedException()
->method('logoutOtherUserSessions')
->willThrowException(new LocalizedException($phrase));
$this->messageManager->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with($phrase);
$this->controller->execute();
}
Expand All @@ -173,7 +173,7 @@ public function testExecuteException()
->method('logoutOtherUserSessions')
->willThrowException(new \Exception());
$this->messageManager->expects($this->once())
->method('addException')
->method('addSuccessMessageptionMessage')
->with(new \Exception(), $phrase);
$this->controller->execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testAroundProlongSessionIsNotActiveAndIsNotAjaxRequest()
->willReturn($errorMessage);

$this->messageManagerMock->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with($errorMessage);

$this->model->aroundProlong($this->authSessionMock, $proceed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testBeforeExecute()
->willReturn($errorMessage);

$this->messageManagerMock->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with($errorMessage);

$this->securityCookieMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ public function execute()
}
$sitemap->delete();
// display success message
$this->messageManager->addSuccess(__('You deleted the sitemap.'));
$this->messageManager->addSuccessMessage(__('You deleted the sitemap.'));
// go to grid
$this->_redirect('adminhtml/*/');
return;
} catch (\Exception $e) {
// display error message
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
// go back to edit form
$this->_redirect('adminhtml/*/edit', ['sitemap_id' => $id]);
return;
}
}
// display error message
$this->messageManager->addError(__('We can\'t find a sitemap to delete.'));
$this->messageManager->addErrorMessage(__('We can\'t find a sitemap to delete.'));
// go to grid
$this->_redirect('adminhtml/*/');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute()
if ($id) {
$model->load($id);
if (!$model->getId()) {
$this->messageManager->addError(__('This sitemap no longer exists.'));
$this->messageManager->addErrorMessage(__('This sitemap no longer exists.'));
$this->_redirect('adminhtml/*/');
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ public function execute()
);
$sitemap->generateXml();

$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('The sitemap "%1" has been generated.', $sitemap->getSitemapFilename())
);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t generate the sitemap right now.'));
$this->messageManager->addExceptionMessage($e, __('We can\'t generate the sitemap right now.'));
} finally {
$this->appEmulation->stopEnvironmentEmulation();
}
} else {
$this->messageManager->addError(__('We can\'t find a sitemap to generate.'));
$this->messageManager->addErrorMessage(__('We can\'t find a sitemap to generate.'));
}

// go to grid
Expand Down
Loading