function CssCollectionOptimizerLazy::deleteAll

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Asset/CssCollectionOptimizerLazy.php \Drupal\Core\Asset\CssCollectionOptimizerLazy::deleteAll()
  2. 10 core/lib/Drupal/Core/Asset/CssCollectionOptimizerLazy.php \Drupal\Core\Asset\CssCollectionOptimizerLazy::deleteAll()

Deletes all optimized asset collections assets.

Overrides AssetCollectionOptimizerInterface::deleteAll

File

core/lib/Drupal/Core/Asset/CssCollectionOptimizerLazy.php, line 134

Class

CssCollectionOptimizerLazy
Optimizes CSS assets.

Namespace

Drupal\Core\Asset

Code

public function deleteAll() {
  if (!\is_dir('assets://css')) {
    return;
  }
  $directory_iterator = new \DirectoryIterator('assets://css');
  $threshold = Settings::get('aggregate_gc_threshold', 86400 * 45);
  foreach ($directory_iterator as $file) {
    if ($file->isFile() && $this->time
      ->getRequestTime() - $file->getMtime() > $threshold) {
      $this->fileSystem
        ->delete($file->getPathName());
    }
  }
}

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