You are here

class CssCollectionOptimizer in Flysystem 8

Same name and namespace in other branches
  1. 3.x src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer
  2. 2.0.x src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer
  3. 3.0.x src/Asset/CssCollectionOptimizer.php \Drupal\flysystem\Asset\CssCollectionOptimizer

Optimizes CSS assets.

Hierarchy

Expanded class hierarchy of CssCollectionOptimizer

2 files declare their use of CssCollectionOptimizer
FlysystemServiceProviderTest.php in tests/src/Unit/FlysystemServiceProviderTest.php
JsCollectionOptimizerTest.php in tests/src/Unit/Asset/JsCollectionOptimizerTest.php

File

src/Asset/CssCollectionOptimizer.php, line 14

Namespace

Drupal\flysystem\Asset
View source
class CssCollectionOptimizer extends DrupalCssCollectionOptimizer {
  use SchemeExtensionTrait;

  /**
   * {@inheritdoc}
   */
  public function deleteAll() {
    $this->state
      ->delete('drupal_css_cache_files');
    $delete_stale = function ($uri) {

      // Default stale file threshold is 30 days.
      if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')
        ->get('stale_file_threshold')) {
        file_unmanaged_delete($uri);
      }
    };
    file_scan_directory($this
      ->getSchemeForExtension('css') . '://css', '/.*/', [
      'callback' => $delete_stale,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CssCollectionOptimizer::$dumper protected property An asset dumper.
CssCollectionOptimizer::$fileSystem protected property The file system service.
CssCollectionOptimizer::$grouper protected property A CSS asset grouper.
CssCollectionOptimizer::$optimizer protected property A CSS asset optimizer.
CssCollectionOptimizer::$state protected property The state key/value store.
CssCollectionOptimizer::deleteAll public function Deletes all optimized asset collections assets. Overrides CssCollectionOptimizer::deleteAll
CssCollectionOptimizer::generateHash protected function Generate a hash for a given group of CSS assets.
CssCollectionOptimizer::getAll public function Returns all optimized asset collections assets. Overrides AssetCollectionOptimizerInterface::getAll
CssCollectionOptimizer::optimize 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::optimize
CssCollectionOptimizer::__construct public function Constructs a CssCollectionOptimizer.
SchemeExtensionTrait::getSchemeForExtension public function Returns the scheme that should serve an extension.