Same name in other branches
  1. 5.0.x advagg.drush.inc \drush_advagg_clear_all_files()
  2. 7.x-2.x advagg.drush.inc \drush_advagg_clear_all_files()
  3. 8.x-2.x advagg.drush.inc \drush_advagg_clear_all_files()
  4. 8.x-3.x advagg.drush.inc \drush_advagg_clear_all_files()
  5. 8.x-4.x advagg.drush.inc \drush_advagg_clear_all_files()

Callback function for drush advagg-clear-all-files.

Related topics

1 call to drush_advagg_clear_all_files()
drush_advagg_force_new_aggregates in ./advagg.drush.inc
Callback function for drush advagg-force-new-aggregates.

File

./advagg.drush.inc, line 131

Code

function drush_advagg_clear_all_files() {
    $file_system = \Drupal::service('file_system');
    // Clear out the cache.
    Cache::invalidateTags([
        'library_info',
    ]);
    \Drupal::cache('advagg')->invalidateAll();
    $pub = $file_system->realpath('public://');
    $css_count = count(glob($pub . '/css/optimized/*.css'));
    $js_count = count(glob($pub . '/js/optimized/*.js'));
    foreach ([
        'public://js/optimized',
        'public://css/optimized',
    ] as $path) {
        if (file_exists($path)) {
            $file_system->deleteRecursive($path);
        }
    }
    // Report back the results.
    \Drupal::logger(dt('All AdvAgg optimized files have been deleted. %css_count CSS files and %js_count JS files have been removed.', [
        '%css_count' => $css_count,
        '%js_count' => $js_count,
    ]));
}