class CssCollectionOptimizer in Flysystem 3.0.x
Same name and namespace in other branches
- 8 src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer
- 3.x src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer
- 2.0.x src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer
Optimizes CSS assets.
Hierarchy
- class \Drupal\Core\Asset\CssCollectionOptimizer implements AssetCollectionOptimizerInterface
- class \Drupal\flysystem\Asset\CssCollectionOptimizer uses SchemeExtensionTrait
Expanded class hierarchy of CssCollectionOptimizer
2 files declare their use of CssCollectionOptimizer
- CollectionOptimizerTest.php in tests/
src/ Kernel/ CollectionOptimizerTest.php - FlysystemServiceProviderTest.php in tests/
src/ Unit/ FlysystemServiceProviderTest.php
File
- src/
Asset/ CssCollectionOptimizer.php, line 10
Namespace
Drupal\flysystem\AssetView source
class CssCollectionOptimizer extends DrupalCssCollectionOptimizer {
use SchemeExtensionTrait;
/**
* {@inheritdoc}
*/
public function deleteAll() {
$this->state
->delete('drupal_css_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);
}
};
$file_system
->scanDirectory($this
->getSchemeForExtension('css') . '://css', '/.*/', [
'callback' => $delete_stale,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CssCollectionOptimizer:: |
protected | property | An asset dumper. | |
CssCollectionOptimizer:: |
protected | property | The file system service. | |
CssCollectionOptimizer:: |
protected | property | A CSS asset grouper. | |
CssCollectionOptimizer:: |
protected | property | A CSS asset optimizer. | |
CssCollectionOptimizer:: |
protected | property | The state key/value store. | |
CssCollectionOptimizer:: |
public | function |
Deletes all optimized asset collections assets. Overrides CssCollectionOptimizer:: |
|
CssCollectionOptimizer:: |
protected | function | Generate a hash for a given group of CSS assets. | |
CssCollectionOptimizer:: |
public | function |
Returns all optimized asset collections assets. Overrides AssetCollectionOptimizerInterface:: |
|
CssCollectionOptimizer:: |
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 file names
in $css while the value is the cache file name. The cache file is generated
in two cases. First, if… Overrides AssetCollectionOptimizerInterface:: |
|
CssCollectionOptimizer:: |
public | function | Constructs a CssCollectionOptimizer. | |
SchemeExtensionTrait:: |
public | function | Returns the scheme that should serve an extension. |