HistoryController.php in Drupal 8
File
core/modules/history/src/Controller/HistoryController.php
View source
<?php
namespace Drupal\history\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Core\Controller\ControllerBase;
use Drupal\node\NodeInterface;
class HistoryController extends ControllerBase {
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));
}
public function readNode(Request $request, NodeInterface $node) {
if ($this
->currentUser()
->isAnonymous()) {
throw new AccessDeniedHttpException();
}
history_write($node
->id());
return new JsonResponse((int) history_read($node
->id()));
}
}