You are here

public function ActivityNotifications::markEntityNotificationsAsRead in Open Social 8

Same name and namespace in other branches
  1. 8.2 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()
  2. 8.3 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()
  3. 8.4 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()
  4. 8.5 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()
  5. 8.6 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()
  6. 8.7 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::markEntityNotificationsAsRead()

Mark Notifications as Read for given account and entity..

Parameters

\Drupal\Core\Session\AccountInterface $account: Account object.

\Drupal\Core\Entity\Entity $entity: Entity object.

File

modules/custom/activity_creator/src/ActivityNotifications.php, line 82

Class

ActivityNotifications
Class ActivityNotifications to get Personalised activity items for account.

Namespace

Drupal\activity_creator

Code

public function markEntityNotificationsAsRead(AccountInterface $account, Entity $entity) {

  // Retrieve all the activities referring this entity for this account.
  $ids = $this
    ->getNotificationIds($account, [
    ACTIVITY_STATUS_RECEIVED,
    ACTIVITY_STATUS_SEEN,
  ], $entity);
  foreach ($ids as $activity_id) {
    $activity = Activity::load($activity_id);
    $this
      ->changeStatusOfActivity($activity, ACTIVITY_STATUS_READ);
  }
}