function JsCollectionOptimizer::deleteAll

Same name in other branches
  1. 9 core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php \Drupal\Core\Asset\JsCollectionOptimizer::deleteAll()
  2. 8.9.x core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php \Drupal\Core\Asset\JsCollectionOptimizer::deleteAll()

Overrides AssetCollectionOptimizerInterface::deleteAll

File

core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php, line 203

Class

JsCollectionOptimizer
Optimizes JavaScript assets.

Namespace

Drupal\Core\Asset

Code

public function deleteAll() {
    $this->state
        ->delete('system.js_cache_files');
    $delete_stale = function ($uri) {
        // Default stale file threshold is 30 days.
        if (\Drupal::time()->getRequestTime() - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
            $this->fileSystem
                ->delete($uri);
        }
    };
    if (is_dir('assets://js')) {
        $this->fileSystem
            ->scanDirectory('assets://js', '/.*/', [
            'callback' => $delete_stale,
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.