You are here

public function NotificationsController::getNotificationListCallback in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()
  2. 8.8 modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()
  3. 10.3.x modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()
  4. 10.0.x modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()
  5. 10.1.x modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()
  6. 10.2.x modules/custom/activity_creator/src/Controller/NotificationsController.php \Drupal\activity_creator\Controller\NotificationsController::getNotificationListCallback()

Get the notification list.

Return value

\Drupal\Core\Ajax\AjaxResponse Returns a render array list of notifications.

Throws

\Drupal\Core\Entity\EntityStorageException

1 string reference to 'NotificationsController::getNotificationListCallback'
activity_creator.routing.yml in modules/custom/activity_creator/activity_creator.routing.yml
modules/custom/activity_creator/activity_creator.routing.yml

File

modules/custom/activity_creator/src/Controller/NotificationsController.php, line 81

Class

NotificationsController
Notifications controller.

Namespace

Drupal\activity_creator\Controller

Code

public function getNotificationListCallback() : AjaxResponse {

  // The data to display, will be the view.
  $view = Views::getView('activity_stream_notifications');
  $view
    ->setDisplay('block_1');
  $rendered_view = $view
    ->render();
  $notification_count = (string) $this->activities
    ->markAllNotificationsAsSeen($this->user);

  // Create a response.
  $response = new AjaxResponse();
  $response
    ->addCommand(new HtmlCommand('.js-notification-center-wrapper', $rendered_view));

  // Update the notification count to mark as read.
  $response
    ->addCommand(new HtmlCommand('.notification-bell .badge', $notification_count));
  return $response;
}