You are here

function social_activity_social_account_notifications_counter in Open Social 8.9

Same name and namespace in other branches
  1. 8.7 modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()
  2. 8.8 modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()
  3. 10.3.x modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()
  4. 10.0.x modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()
  5. 10.1.x modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()
  6. 10.2.x modules/social_features/social_activity/social_activity.module \social_activity_social_account_notifications_counter()

Wrapper method to get the number of unread notifications.

Parameters

\Drupal\Core\Session\AccountInterface $account: Account object to get notifications for.

array $status: Filter by status.

Return value

int|void Returns the amount of notifications.

See also

\Drupal\activity_creator\ActivityNotifications

3 calls to social_activity_social_account_notifications_counter()
social_activity_social_user_account_header_account_links in modules/social_features/social_activity/social_activity.module
Implements hook_social_user_account_header_account_links().
social_activity_social_user_account_header_items in modules/social_features/social_activity/social_activity.module
Implements hook_social_user_account_header_items().
social_activity_social_user_account_header_items_alter in modules/social_features/social_activity/social_activity.module
Implements hook_social_user_account_header_items().

File

modules/social_features/social_activity/social_activity.module, line 213
The Social activity module.

Code

function social_activity_social_account_notifications_counter(AccountInterface $account, array $status = [
  ACTIVITY_STATUS_RECEIVED,
]) {
  $account_notifications = \Drupal::service('activity_creator.activity_notifications');
  return count($account_notifications
    ->getNotifications($account, $status)) ?? 0;
}