You are here

public function NotificationsController::readNotificationCallback in Open Social 8.2

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

Ajax callback to mark notifications as read.

1 string reference to 'NotificationsController::readNotificationCallback'
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 16

Class

NotificationsController
Notifications controller.

Namespace

Drupal\activity_creator\Controller

Code

public function readNotificationCallback() {
  $account = \Drupal::currentUser();

  // @todo: Add dependency injection.
  $activity_notifications = \Drupal::service('activity_creator.activity_notifications');
  $remaining_notifications = $activity_notifications
    ->markAllNotificationsAsSeen($account);

  // Create AJAX Response object.
  // @todo: Implement a Ajax command instead and call via addCommand().
  $response = new AjaxResponse();
  $data = [
    'remaining_notifications' => $remaining_notifications,
  ];
  $response
    ->setData($data);

  // Return ajax response.
  return $response;
}