CssOptimizer
class CssOptimizer implements AssetOptimizerInterface (View source)
Optimizes a CSS asset.
Properties
| string | $rewriteFileURIBasePath | The base path used by rewriteFileURI(). |
|
| protected FileUrlGeneratorInterface | $fileUrlGenerator | The file URL generator. |
Methods
Optimizes an asset.
Processes the contents of a CSS asset for cleanup.
Build aggregate CSS file.
Loads the stylesheet and resolves all @import commands.
Loads stylesheets recursively and returns contents with corrected paths.
Processes the contents of a stylesheet for aggregation.
Prefixes all paths within a CSS file for processFile().
Details
__construct(FileUrlGeneratorInterface $file_url_generator = NULL)
Constructs a CssOptimizer.
string
optimize(array $css_asset)
Optimizes an asset.
string
clean(string $contents)
Processes the contents of a CSS asset for cleanup.
protected
processFile($css_asset)
Build aggregate CSS file.
Contents
loadFile($file, $optimize = NULL, $reset_basepath = TRUE)
Loads the stylesheet and resolves all @import commands.
Loads a stylesheet and replaces @import commands with the contents of the imported file. Use this instead of file_get_contents when processing stylesheets.
The returned contents are compressed removing white space and comments only when CSS aggregation is enabled. This optimization will not apply for color.module enabled themes with CSS aggregation turned off.
Note: the only reason this method is public is so color.module can call it; it is not on the AssetOptimizerInterface, so future refactorings can make it protected.
protected The
loadNestedFile(array $matches)
Loads stylesheets recursively and returns contents with corrected paths.
This function is used for recursive loading of stylesheets and returns the stylesheet content with all url() paths corrected.
protected Contents
processCss($contents, $optimize = FALSE)
Processes the contents of a stylesheet for aggregation.
string
rewriteFileURI(array $matches)
Prefixes all paths within a CSS file for processFile().
Note: the only reason this method is public is so color.module can call it; it is not on the AssetOptimizerInterface, so future refactorings can make it protected.