You are here

public function OperationsForm::clearStaleAggregates in Advanced CSS/JS Aggregation 8.2

Same name and namespace in other branches
  1. 8.4 src/Form/OperationsForm.php \Drupal\advagg\Form\OperationsForm::clearStaleAggregates()
  2. 8.3 src/Form/OperationsForm.php \Drupal\advagg\Form\OperationsForm::clearStaleAggregates()

Clear out all stale advagg aggregated files.

File

src/Form/OperationsForm.php, line 348

Class

OperationsForm
Configure advagg settings for this site.

Namespace

Drupal\advagg\Form

Code

public function clearStaleAggregates() {

  // Run the command.
  $css_count = count($this->cssCollectionOptimizer
    ->deleteStale());
  $js_count = count($this->jsCollectionOptimizer
    ->deleteStale());

  // Report back the results.
  if ($css_count || $js_count) {
    drupal_set_message($this
      ->t('All stale aggregates have been deleted. %css_count CSS files and %js_count JS files have been removed.', [
      '%css_count' => $css_count,
      '%js_count' => $js_count,
    ]));
  }
  else {
    drupal_set_message($this
      ->t('No stale aggregates found. Nothing was deleted.'));
  }
}