Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MarkAsRead.php
Go to the documentation of this file.
1 <?php
8 
10 {
16  const ADMIN_RESOURCE = 'Magento_AdminNotification::mark_as_read';
17 
21  public function execute()
22  {
23  $notificationId = (int)$this->getRequest()->getParam('id');
24  if ($notificationId) {
25  try {
26  $this->_objectManager->create(
27  \Magento\AdminNotification\Model\NotificationService::class
28  )->markAsRead(
29  $notificationId
30  );
31  $this->messageManager->addSuccessMessage(__('The message has been marked as Read.'));
32  } catch (\Magento\Framework\Exception\LocalizedException $e) {
33  $this->messageManager->addErrorMessage($e->getMessage());
34  } catch (\Exception $e) {
35  $this->messageManager->addExceptionMessage(
36  $e,
37  __("We couldn't mark the notification as Read because of an error.")
38  );
39  }
40 
41  $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
42  return;
43  }
44  $this->_redirect('adminhtml/*/');
45  }
46 }
__()
Definition: __.php:13