You are here

public function HistoryController::getNodeReadTimestamps in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::getNodeReadTimestamps()
  2. 10 core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::getNodeReadTimestamps()

Returns a set of nodes' last read timestamps.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request of the page.

Return value

Symfony\Component\HttpFoundation\JsonResponse The JSON response.

1 string reference to 'HistoryController::getNodeReadTimestamps'
history.routing.yml in core/modules/history/history.routing.yml
core/modules/history/history.routing.yml

File

core/modules/history/src/Controller/HistoryController.php, line 26

Class

HistoryController
Returns responses for History module routes.

Namespace

Drupal\history\Controller

Code

public function getNodeReadTimestamps(Request $request) {
  if ($this
    ->currentUser()
    ->isAnonymous()) {
    throw new AccessDeniedHttpException();
  }
  $nids = $request->request
    ->get('node_ids');
  if (!isset($nids)) {
    throw new NotFoundHttpException();
  }
  return new JsonResponse(history_read_multiple($nids));
}