You are here

protected function ActivityNotifications::getNotificationIds in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  2. 8 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  3. 8.2 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  4. 8.3 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  5. 8.4 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  6. 8.5 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  7. 8.6 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  8. 8.7 modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  9. 10.3.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  10. 10.0.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  11. 10.1.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()
  12. 10.2.x modules/custom/activity_creator/src/ActivityNotifications.php \Drupal\activity_creator\ActivityNotifications::getNotificationIds()

Returns the Activity ids for an account with destination 'notification'.

Parameters

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

array $status: Array of notification statuses.

Return value

array Returns an array of notification ids or empty array.

4 calls to ActivityNotifications::getNotificationIds()
ActivityNotifications::getNotifications in modules/custom/activity_creator/src/ActivityNotifications.php
Returns the Notifications for a given account.
ActivityNotifications::getNotificationsActivities in modules/custom/activity_creator/src/ActivityNotifications.php
Returns the Activity objects with destination 'notification' for account.
ActivityNotifications::markAllNotificationsAsSeen in modules/custom/activity_creator/src/ActivityNotifications.php
Mark all notifications as Seen for account.
ActivityNotifications::markEntityAsRead in modules/custom/activity_creator/src/ActivityNotifications.php
Mark an entity as read for a given account.

File

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

Class

ActivityNotifications
Class ActivityNotifications to get Personalised activity items for account.

Namespace

Drupal\activity_creator

Code

protected function getNotificationIds(AccountInterface $account, array $status = []) : array {

  // Get the user ID.
  if (!empty($uid = $account
    ->id())) {
    try {
      $query = $this->database
        ->select('activity_notification_status', 'ans')
        ->fields('ans', [
        'aid',
      ])
        ->condition('uid', $uid);
      if (!empty($status)) {
        $query
          ->condition('status', $status, 'IN');
      }
      return $query
        ->execute()
        ->fetchCol();
    } catch (\Exception $exception) {

      // Log the exception to watchdog.
      $this
        ->getLogger('default')
        ->error($exception
        ->getMessage());
    }
  }
  else {
    return [];
  }
}