_tracker_calculate_changed

_tracker_calculate_changed($node)

Picks the most recent timestamp between node changed and the last comment.

@todo Check if we should introduce 'language context' here, because the callers may need different timestamps depending on the users' language?

Parameters

\Drupal\node\NodeInterface $node: The node entity.

Return value

int The node changed timestamp, or most recent comment timestamp, whichever is the greatest.

File

core/modules/tracker/tracker.module, line 294
Tracks recent content posted by a user or users.

Code

function _tracker_calculate_changed($node) {
  $changed = $node->getChangedTime();
  $latest_comment = \Drupal::service('comment.statistics')->read(array($node), 'node', FALSE);
  if ($latest_comment && $latest_comment->last_comment_timestamp > $changed) {
    $changed = $latest_comment->last_comment_timestamp;
  }
  return $changed;
}
doc_Drupal
2016-10-29 09:57:20
Comments
Leave a Comment

Please login to continue.