You are here

class JsCollectionOptimizer in Flysystem 8

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

Optimizes JavaScript assets.

Hierarchy

Expanded class hierarchy of JsCollectionOptimizer

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

File

src/Asset/JsCollectionOptimizer.php, line 14

Namespace

Drupal\flysystem\Asset
View source
class JsCollectionOptimizer extends DrupalJsCollectionOptimizer {
  use SchemeExtensionTrait;

  /**
   * {@inheritdoc}
   */
  public function deleteAll() {
    $this->state
      ->delete('system.js_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('js') . '://js', '/.*/', [
      'callback' => $delete_stale,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JsCollectionOptimizer::$dumper protected property An asset dumper.
JsCollectionOptimizer::$fileSystem protected property The file system service.
JsCollectionOptimizer::$grouper protected property A JS asset grouper.
JsCollectionOptimizer::$optimizer protected property A JS asset optimizer.
JsCollectionOptimizer::$state protected property The state key/value store.
JsCollectionOptimizer::deleteAll public function Deletes all optimized asset collections assets. Overrides JsCollectionOptimizer::deleteAll
JsCollectionOptimizer::generateHash protected function Generate a hash for a given group of JavaScript assets.
JsCollectionOptimizer::getAll public function Returns all optimized asset collections assets. Overrides AssetCollectionOptimizerInterface::getAll
JsCollectionOptimizer::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 names in $files while the value is the cache file name. The cache file is generated in two cases. First, if… Overrides AssetCollectionOptimizerInterface::optimize
JsCollectionOptimizer::__construct public function Constructs a JsCollectionOptimizer.
SchemeExtensionTrait::getSchemeForExtension public function Returns the scheme that should serve an extension.