public static function OpignoNotification::unreadCount in Opigno notifications 8
Same name and namespace in other branches
- 3.x src/Entity/OpignoNotification.php \Drupal\opigno_notification\Entity\OpignoNotification::unreadCount()
Returns unread notifications count.
Parameters
\Drupal\user\Entity\User|null $account: User for which notifications will be counted. Current user if not specified.
Return value
int Unread notifications count.
2 calls to OpignoNotification::unreadCount()
- OpignoNotificationController::count in src/
Controller/ OpignoNotificationController.php - Ajax callback. Returns unread notifications count.
- OpignoNotificationController::getMessages in src/
Controller/ OpignoNotificationController.php - Ajax callback. Get messages and its count.
File
- src/
Entity/ OpignoNotification.php, line 124
Class
- OpignoNotification
- Defines the opigno_notification entity.
Namespace
Drupal\opigno_notification\EntityCode
public static function unreadCount($account = NULL) {
if ($account === NULL) {
$account = \Drupal::currentUser();
}
$query = \Drupal::entityQuery('opigno_notification');
$query
->condition('uid', $account
->id());
$query
->condition('has_read', FALSE);
$query
->count();
$result = $query
->execute();
return (int) $result;
}