You are here

class S3fsCssOptimizer in S3 File System 8.2

Optimizes a CSS asset.

Hierarchy

Expanded class hierarchy of S3fsCssOptimizer

File

src/S3fsCssOptimizer.php, line 10

Namespace

Drupal\s3fs
View source
class S3fsCssOptimizer extends CssOptimizer {

  /**
   * Return absolute urls to access static files that they aren't in S3 bucket.
   *
   * @param array $matches
   *   An array of matches by a preg_replace_callback() call that scans for
   *   url() references in CSS files, except for external or absolute ones.
   *
   * @return string
   *   The file path.
   */
  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);
    }
    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.
S3fsCssOptimizer::rewriteFileURI public function Return absolute urls to access static files that they aren't in S3 bucket. Overrides CssOptimizer::rewriteFileURI