You are here

class CssOptimizer in Flysystem 8

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

Changes Drupal\Core\Asset\CssOptimizer to not remove absolute URLs.

@codeCoverageIgnore

Hierarchy

Expanded class hierarchy of CssOptimizer

1 file declares its use of CssOptimizer
FlysystemServiceProviderTest.php in tests/src/Unit/FlysystemServiceProviderTest.php

File

src/Asset/CssOptimizer.php, line 12

Namespace

Drupal\flysystem\Asset
View source
class CssOptimizer extends DrupalCssOptimizer {

  /**
   * {@inheritdoc}
   */
  public function rewriteFileURI($matches) {

    // Prefix with base and remove '../' segments where possible.
    $path = $this->rewriteFileURIBasePath . $matches[1];
    $last = '';
    while ($path != $last) {
      $last = $path;
      $path = preg_replace('`(^|/)(?!\\.\\./)([^/]+)/\\.\\./`', '$1', $path);
    }

    // file_url_transform_relative() was removed here.
    return 'url(' . file_create_url($path) . ')';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CssOptimizer::$rewriteFileURIBasePath public property The base path used by rewriteFileURI().
CssOptimizer::clean public function Processes the contents of a CSS asset for cleanup. Overrides AssetOptimizerInterface::clean
CssOptimizer::loadFile public function Loads the stylesheet and resolves all @import commands.
CssOptimizer::loadNestedFile protected function Loads stylesheets recursively and returns contents with corrected paths.
CssOptimizer::optimize public function Optimizes an asset. Overrides AssetOptimizerInterface::optimize
CssOptimizer::processCss protected function Processes the contents of a stylesheet for aggregation.
CssOptimizer::processFile protected function Build aggregate CSS file.
CssOptimizer::rewriteFileURI public function Prefixes all paths within a CSS file for processFile(). Overrides CssOptimizer::rewriteFileURI