You are here

function advagg_cron in Advanced CSS/JS Aggregation 8.2

Same name and namespace in other branches
  1. 8.4 advagg.module \advagg_cron()
  2. 8.3 advagg.module \advagg_cron()
  3. 6 advagg.module \advagg_cron()
  4. 7.2 advagg.module \advagg_cron()
  5. 7 advagg.module \advagg_cron()

Implements hook_cron().

This will be ran once a day at most.

Parameters

bool $bypass_time_check: Set to TRUE to skip the 24 hour check.

1 call to advagg_cron()
drush_advagg_cron in ./advagg.drush.inc
Callback function for drush advagg-cron.

File

./advagg.module, line 98
Advanced CSS/JS aggregation module.

Code

function advagg_cron($bypass_time_check = FALSE) {
  $state = \Drupal::state();

  // Execute once a day (24 hours).
  if (!$bypass_time_check && $state
    ->get('advagg.cron_timestamp', REQUEST_TIME) > REQUEST_TIME - \Drupal::config('advagg.settings')
    ->get('cron_frequency')) {
    return [];
  }
  $state
    ->set('advagg.cron_timestamp', REQUEST_TIME);
  $return = [];
  $return['stale'] = [
    'js' => \Drupal::service('asset.js.collection_optimizer')
      ->deleteStale(),
    'css' => \Drupal::service('asset.css.collection_optimizer')
      ->deleteStale(),
  ];
  return $return;
}