function JsCollectionOptimizerLazy::deleteAll

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

Deletes all optimized asset collections assets.

Overrides AssetCollectionOptimizerInterface::deleteAll

File

core/lib/Drupal/Core/Asset/JsCollectionOptimizerLazy.php, line 148

Class

JsCollectionOptimizerLazy
Optimizes JavaScript assets.

Namespace

Drupal\Core\Asset

Code

public function deleteAll() {
  if (!\is_dir('assets://js')) {
    return;
  }
  $directory_iterator = new \DirectoryIterator('assets://js');
  $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.