class JsCollectionOptimizer in Flysystem 2.0.x
Same name and namespace in other branches
- 8 src/Asset/JsCollectionOptimizer.php \Drupal\flysystem\Asset\JsCollectionOptimizer
- 3.x src/Asset/JsCollectionOptimizer.php \Drupal\flysystem\Asset\JsCollectionOptimizer
- 3.0.x src/Asset/JsCollectionOptimizer.php \Drupal\flysystem\Asset\JsCollectionOptimizer
Optimizes JavaScript assets.
Hierarchy
- class \Drupal\Core\Asset\JsCollectionOptimizer implements AssetCollectionOptimizerInterface
- class \Drupal\flysystem\Asset\JsCollectionOptimizer uses SchemeExtensionTrait
Expanded class hierarchy of JsCollectionOptimizer
2 files declare their use of JsCollectionOptimizer
- CollectionOptimizerTest.php in tests/
src/ Kernel/ CollectionOptimizerTest.php - FlysystemServiceProviderTest.php in tests/
src/ Unit/ FlysystemServiceProviderTest.php
File
- src/
Asset/ JsCollectionOptimizer.php, line 10
Namespace
Drupal\flysystem\AssetView source
class JsCollectionOptimizer extends DrupalJsCollectionOptimizer {
use SchemeExtensionTrait;
/**
* {@inheritdoc}
*/
public function deleteAll() {
$this->state
->delete('system.js_cache_files');
/** @var \Drupal\Core\File\FileSystem $file_system */
$file_system = \Drupal::service('file_system');
$delete_stale = static function ($uri) use ($file_system) {
// Default stale file threshold is 30 days (2592000 seconds).
$stale_file_threshold = \Drupal::config('system.performance')
->get('stale_file_threshold') ?? 2592000;
if (\Drupal::time()
->getRequestTime() - filemtime($uri) > $stale_file_threshold) {
$file_system
->delete($uri);
}
};
$js_dir = $this
->getSchemeForExtension('js') . '://js';
if (is_dir($js_dir)) {
$file_system
->scanDirectory($js_dir, '/.*/', [
'callback' => $delete_stale,
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JsCollectionOptimizer:: |
protected | property | An asset dumper. | |
JsCollectionOptimizer:: |
protected | property | The file system service. | |
JsCollectionOptimizer:: |
protected | property | A JS asset grouper. | |
JsCollectionOptimizer:: |
protected | property | A JS asset optimizer. | |
JsCollectionOptimizer:: |
protected | property | The state key/value store. | |
JsCollectionOptimizer:: |
public | function |
Deletes all optimized asset collections assets. Overrides JsCollectionOptimizer:: |
|
JsCollectionOptimizer:: |
protected | function | Generate a hash for a given group of JavaScript assets. | |
JsCollectionOptimizer:: |
public | function |
Returns all optimized asset collections assets. Overrides AssetCollectionOptimizerInterface:: |
|
JsCollectionOptimizer:: |
public | function |
The cache file name is retrieved on a page load via a lookup variable that
contains an associative array. The array key is the hash of the names in
$files while the value is the cache file name. The cache file is generated
in two cases. First, if… Overrides AssetCollectionOptimizerInterface:: |
|
JsCollectionOptimizer:: |
public | function | Constructs a JsCollectionOptimizer. | |
SchemeExtensionTrait:: |
public | function | Returns the scheme that should serve an extension. |