Same name and namespace in other branches
  1. 5.0.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
  2. 6.0.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()
  3. 8.x-3.x advagg_css_minify/src/Asset/CssMinifier.php \Drupal\advagg_css_minify\Asset\CssMinifier::minifyCssMin()

Processes the contents of a stylesheet through CSSMin for minification.

Paramètres

string $contents: The contents of the stylesheet.

Return value

string Minified contents of the stylesheet including the imported stylesheets.

1 call to CssMinifier::minifyCssMin()
CssMinifier::optimize dans advagg_css_minify/src/Asset/CssMinifier.php
Optimize the asset's content.

Fichier

advagg_css_minify/src/Asset/CssMinifier.php, line 109

Classe

CssMinifier
Optimizes a JavaScript asset.

Namespace

Drupal\advagg_css_minify\Asset

Code

protected function minifyCssMin($contents) {
    $cssmin = new CSSmin(TRUE);
    // Minify the CSS splitting lines after 4k of text.
    $contents = $cssmin->run($contents, 4096);
    // Replaces @import commands with the actual stylesheet content.
    // This happens recursively but omits external files.
    $contents = preg_replace_callback('/@import\\s*(?:url\\(\\s*)?[\'"]?(?![a-z]+:)(?!\\/\\/)([^\'"\\()]+)[\'"]?\\s*\\)?\\s*;/', [
        $this,
        'loadNestedFile',
    ], $contents);
    return $contents;
}