Skip to content

Commit 744b0f7

Browse files
committed
ObjectManager cleanup - Remove usage from AdminNotification module
Fix small issues after code review
1 parent d359cdf commit 744b0f7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/code/Magento/AdminNotification/Block/System/Messages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function getLastCritical()
7474
{
7575
$items = array_values($this->_messages->getItems());
7676

77-
if (isset($items[0]) && (int)$items[0]->getSeverity() === MessageInterface::SEVERITY_CRITICAL) {
78-
return $items[0];
77+
if (!empty($items) && current($items)->getSeverity() === MessageInterface::SEVERITY_CRITICAL) {
78+
return current($items);
7979
}
8080
return null;
8181
}

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\AdminNotification\Controller\Adminhtml\Notification;
1010
use Magento\AdminNotification\Model\NotificationService;
1111
use Magento\Backend\App\Action;
12+
use Magento\Framework\Exception\LocalizedException;
1213

1314
class MarkAsRead extends Notification
1415
{
@@ -40,7 +41,7 @@ public function execute()
4041
try {
4142
$this->notificationService->markAsRead($notificationId);
4243
$this->messageManager->addSuccessMessage(__('The message has been marked as Read.'));
43-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
44+
} catch (LocalizedException $e) {
4445
$this->messageManager->addErrorMessage($e->getMessage());
4546
} catch (\Exception $e) {
4647
$this->messageManager->addExceptionMessage(

0 commit comments

Comments
 (0)