function _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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!tracker!tracker.module/function/_tracker_calculate_changed/8.1.x