You are here

public function OpignoNotificationController::getMessages in Opigno notifications 8

Same name and namespace in other branches
  1. 3.x src/Controller/OpignoNotificationController.php \Drupal\opigno_notification\Controller\OpignoNotificationController::getMessages()

Ajax callback. Get messages and its count.

1 string reference to 'OpignoNotificationController::getMessages'
opigno_notification.routing.yml in ./opigno_notification.routing.yml
opigno_notification.routing.yml

File

src/Controller/OpignoNotificationController.php, line 76

Class

OpignoNotificationController
Provides the controller for OpignoNotification entity pages.

Namespace

Drupal\opigno_notification\Controller

Code

public function getMessages() {
  $uid = \Drupal::currentUser()
    ->id();
  $renderer = \Drupal::service('renderer');
  $variables = [];
  $notifications_unread = views_embed_view('opigno_notifications', 'block_unread', $uid);
  $private_messages = views_embed_view('private_message', 'block_last', $uid);
  $variables['notifications_unread_count'] = OpignoNotification::unreadCount();
  $variables['notifications_unread'] = $renderer
    ->render($notifications_unread);
  $variables['private_messages'] = $renderer
    ->render($private_messages);
  $variables['unread_thread_count'] = OpignoMessageThread::getUnreadThreadCount();
  return new JsonResponse($variables);
}