HistoryController::readNode

public HistoryController::readNode(Request $request, NodeInterface $node)

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.

File

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

Class

HistoryController
Returns responses for History module routes.

Namespace

Drupal\history\Controller

Code

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()));
}
doc_Drupal
2016-10-29 09:17:42
Comments
Leave a Comment

Please login to continue.