1<?php 2 3namespace Drupal\history; 4 5use Drupal\Core\Render\Element\RenderCallbackInterface; 6 7/** 8 * Render callback object. 9 */ 10class HistoryRenderCallback implements RenderCallbackInterface { 11 12 /** 13 * #lazy_builder callback; attaches the last read timestamp for a node. 14 * 15 * @param int $node_id 16 * The node ID for which to attach the last read timestamp. 17 * 18 * @return array 19 * A renderable array containing the last read timestamp. 20 */ 21 public static function lazyBuilder($node_id) { 22 $element = []; 23 $element['#attached']['drupalSettings']['history']['lastReadTimestamps'][$node_id] = (int) history_read($node_id); 24 return $element; 25 } 26 27} 28