function CssCollectionOptimizer::deleteAll

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

Overrides AssetCollectionOptimizerInterface::deleteAll

File

core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php, line 190

Class

CssCollectionOptimizer
Optimizes CSS assets.

Namespace

Drupal\Core\Asset

Code

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

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