Processes the contents of a stylesheet for minification.
Paramètres
string $contents: The contents of the stylesheet.
string $minifier: The name of the minifier to use.
Return value
string Minified contents of the stylesheet including the imported stylesheets.
1 call to CssOptimizer::processCssOther()
- CssOptimizer::loadFile dans advagg_css_minify/
src/ Asset/ CssOptimizer.php - Loads the stylesheet and resolves all @import commands.
Fichier
-
advagg_css_minify/
src/ Asset/ CssOptimizer.php, line 236
Classe
- CssOptimizer
- Optimizes a CSS asset.
Namespace
Drupal\advagg_css_minify\AssetCode
protected function processCssOther($contents, $minifier) {
$contents = $this->clean($contents);
list(, , , $functions) = $this->getConfiguration();
if (isset($functions[$minifier])) {
$run = $functions[$minifier];
if (function_exists($run)) {
$run($contents);
}
}
// 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;
}