You are here

function acsf_theme_cron in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 acsf_theme/acsf_theme.module \acsf_theme_cron()

Implements hook_cron().

File

acsf_theme/acsf_theme.module, line 11
Manages VCS-based themes on Acquia Cloud Site Factory.

Code

function acsf_theme_cron() {

  // Don't execute on non-ACSF systems.
  if (!empty($GLOBALS['gardens_site_settings'])) {

    // When none of the notification sending succeeded then this variable will
    // contain a timestamp when the next time the cron should run to avoid
    // hammering the factory.
    $cron_next_run = \Drupal::service('acsf.variable_storage')
      ->get('acsf_theme_cron_wait_until', 0);
    if ($cron_next_run < \Drupal::time()
      ->getRequestTime()) {
      $batch_size = \Drupal::service('acsf.variable_storage')
        ->get('acsf_theme_notification_batch_size', 10);
      $success = \Drupal::service('acsf.theme_notification')
        ->processNotifications($batch_size);
      if ($success < 0) {
        $cron_delay = \Drupal::service('acsf.variable_storage')
          ->get('acsf_theme_cron_delay', 600);
        \Drupal::service('acsf.variable_storage')
          ->set('acsf_theme_cron_wait_until', time() + $cron_delay);
      }
    }
  }
}