function HistoryController::readNode
Same name in other branches
- 8.9.x core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::readNode()
- 10 core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::readNode()
- 11.x core/modules/history/src/Controller/HistoryController.php \Drupal\history\Controller\HistoryController::readNode()
Marks a node as read by the current user right now.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request of the page.
\Drupal\node\NodeInterface $node: The node whose "last read" timestamp should be updated.
1 string reference to 'HistoryController::readNode'
- 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 46
Class
- HistoryController
- Returns responses for History module routes.
Namespace
Drupal\history\ControllerCode
public function readNode(Request $request, NodeInterface $node) {
if ($this->currentUser()
->isAnonymous()) {
throw new AccessDeniedHttpException();
}
// Update the history table, stating that this user viewed this node.
history_write($node->id());
return new JsonResponse((int) history_read($node->id()));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.