Delete stale optimized collection assets.

Fichier

src/Asset/JsCollectionOptimizer.php, line 214

Classe

JsCollectionOptimizer

Namespace

Drupal\advagg\Asset

Code

public function deleteStale() {
    $log = [];
    $this->state
        ->delete('system.js_cache_files');
    Cache::invalidateTags([
        'library_info',
    ]);
    $delete_stale = function ($uri) use (&$log) {
        // Default stale file threshold is 30 days.
        if (REQUEST_TIME - fileatime($uri) > $this->systemConfig
            ->get('stale_file_threshold')) {
            file_unmanaged_delete($uri);
            $log[] = $uri;
        }
    };
    file_scan_directory($this->dumper
        ->preparePath('js'), '/.*/', [
        'callback' => $delete_stale,
    ]);
    return $log;
}