function HistoryController::getNodeReadTimestamps

Same name and namespace in other branches
  1. 9 core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::getNodeReadTimestamps()
  2. 8.9.x core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::getNodeReadTimestamps()
  3. 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();
    }
    if (!$request->request
        ->has('node_ids')) {
        throw new NotFoundHttpException();
    }
    $nids = $request->request
        ->all('node_ids');
    return new JsonResponse(history_read_multiple($nids));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.