You are here

function evercurrent_cron in Evercurrent 8

Same name and namespace in other branches
  1. 8.2 evercurrent.module \evercurrent_cron()
  2. 7.2 evercurrent.module \evercurrent_cron()
  3. 7 evercurrent.module \evercurrent_cron()

Implements hook_cron().

File

./evercurrent.module, line 53
Contains evercurrent.module.

Code

function evercurrent_cron() {
  $config = \Drupal::config('evercurrent.admin_config');

  // Check if we are to send updates now.
  if ($config
    ->get('send')) {
    $last_run = Drupal::state()
      ->get('evercurrent_last_run') ?: 0;
    $interval = $config
      ->get('interval');

    // Check if last run plus interval is earlier than now
    if ($last_run + $interval < time()) {

      /** @var UpdateHelper $updateHelper */
      $updateHelper = \Drupal::service('evercurrent.update_helper');
      $updateHelper
        ->sendUpdates(TRUE);
    }
  }
}