You are here

function nodeviewcount_cron in Node view count 8

Same name and namespace in other branches
  1. 7.3 nodeviewcount.module \nodeviewcount_cron()
  2. 7 nodeviewcount.module \nodeviewcount_cron()
  3. 7.2 nodeviewcount.module \nodeviewcount_cron()

Implements hook_cron().

File

./nodeviewcount.module, line 38
Primarily Drupal hooks for nodeviewcount module.

Code

function nodeviewcount_cron() {

  /** @var \Drupal\nodeviewcount\NodeViewCountRecordsManager $records_manager */
  $records_manager = Drupal::service('nodeviewcount.records_manager');
  $logs_life_time = $records_manager
    ->getLogsLifeTime();
  if ($logs_life_time > 0) {
    $records_manager
      ->deleteOldRecords($logs_life_time);
  }
}