1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-17 19:37:22 +02:00

some idea I do not remember

This commit is contained in:
Steve Clay
2014-09-18 17:55:16 -04:00
parent fb3931f8cd
commit 5d4c45ad8c

View File

@@ -0,0 +1,39 @@
<?php
/**
* Class Minify_CSS_Filter_BubbleImports
* @package Minify
*/
/**
* CSS filter that moves @import statements to the top of the CSS
*
* @package Minify
*/
class Minify_CSS_Filter_BubbleImports {
/**
* @param string $css
* @return string
*/
public static function filter($css) {
$importStatements = array();
$collect = function($matches) use (&$importStatements) {
$importStatements[] = $matches[0];
$media = '';
if (trim($matches[2])) {
$media = ' for media:' . $matches[2];
}
return '/* replaced import "'.$matches[1].'"'.$media.' */';
};
$css = preg_replace_callback(Minify_ImportProcessor::IMPORT_STATEMENT_REGEX, $collect, $css);
if ($importStatements) {
$css = join("\n", $importStatements) . "\n" . $css;
}
return $css;
}
}