Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
NotificationService Class Reference

Public Member Functions

 __construct (\Magento\AdminNotification\Model\InboxFactory $notificationFactory)
 
 markAsRead ($notificationId)
 

Protected Attributes

 $_notificationFactory
 

Detailed Description

Notification service model

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m @api
Since
100.0.2

Definition at line 15 of file NotificationService.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\AdminNotification\Model\InboxFactory  $notificationFactory)
Parameters
\Magento\AdminNotification\Model\InboxFactory$notificationFactory

Definition at line 25 of file NotificationService.php.

26  {
27  $this->_notificationFactory = $notificationFactory;
28  }

Member Function Documentation

◆ markAsRead()

markAsRead (   $notificationId)

Mark notification as read

Parameters
int$notificationId
Returns
void
Exceptions

Definition at line 37 of file NotificationService.php.

38  {
39  $notification = $this->_notificationFactory->create();
40  $notification->load($notificationId);
41  if (!$notification->getId()) {
42  throw new \Magento\Framework\Exception\LocalizedException(__('Wrong notification ID specified.'));
43  }
44  $notification->setIsRead(1);
45  $notification->save();
46  }
__()
Definition: __.php:13

Field Documentation

◆ $_notificationFactory

$_notificationFactory
protected

Definition at line 20 of file NotificationService.php.


The documentation for this class was generated from the following file: