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

Processes the contents of a CSS asset for cleanup.

Paramètres

string $contents: The contents of the CSS asset.

array $asset: The core asset definition array.

Return value

string Contents of the CSS asset.

2 calls to CssMinifier::clean()
CssMinifier::loadFile dans advagg_css_minify/src/Asset/CssMinifier.php
Loads the stylesheet and resolves all @import commands.
CssMinifier::optimize dans advagg_css_minify/src/Asset/CssMinifier.php
Optimize the asset's content.

Fichier

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

Classe

CssMinifier
Optimizes a JavaScript asset.

Namespace

Drupal\advagg_css_minify\Asset

Code

protected function clean($contents, array $asset) {
    if ($encoding = Unicode::encodingFromBOM($contents)) {
        $contents = mb_substr(Unicode::convertToUtf8($contents, $encoding), 1);
    }
    elseif (isset($asset['attributes']['charset'])) {
        $contents = Unicode::convertToUtf8($contents, $asset['attributes']['charset']);
    }
    elseif (preg_match('/^@charset "([^"]+)";/', $contents, $matches)) {
        if ($matches[1] !== 'utf-8' && $matches[1] !== 'UTF-8') {
            $contents = substr($contents, strlen($matches[0]));
            $contents = Unicode::convertToUtf8($contents, $matches[1]);
        }
    }
    // Remove multiple charset declarations for standards compliance (and fixing
    // Safari problems).
    $contents = preg_replace('/^@charset\\s+[\'"](\\S*?)\\b[\'"];/i', '', $contents);
    return $contents;
}