22 const REGEX_IMPORTS =
'/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/';
37 $content = static::filterUrls($content, $callback);
38 $content = static::filterImports($content, $callback,
false);
39 $content = static::filterIEFilters($content, $callback);
54 $pattern = static::REGEX_URLS;
56 return static::filterCommentless($content,
function ($part) use (& $callback, $pattern) {
57 return preg_replace_callback($pattern, $callback, $part);
70 public static function filterImports($content, $callback, $includeUrl =
true)
72 $pattern = $includeUrl ? static::REGEX_IMPORTS : static::REGEX_IMPORTS_NO_URLS;
74 return static::filterCommentless($content,
function ($part) use (& $callback, $pattern) {
75 return preg_replace_callback($pattern, $callback, $part);
89 $pattern = static::REGEX_IE_FILTERS;
91 return static::filterCommentless($content,
function ($part) use (& $callback, $pattern) {
92 return preg_replace_callback($pattern, $callback, $part);
107 foreach (preg_split(static::REGEX_COMMENTS, $content, -1, PREG_SPLIT_DELIM_CAPTURE) as $part) {
108 if (!preg_match(static::REGEX_COMMENTS, $part, $match) || $part != $match[0]) {
109 $part = call_user_func($callback, $part);
128 static::filterImports($content,
function ($matches) use (&$imports) {
129 $imports[] = $matches[
'url'];
132 return array_unique($imports);
static filterUrls($content, $callback)
Filters all CSS url()'s through a callable.
static extractImports($content)
Extracts all references from the supplied CSS content.
static filterCommentless($content, $callback)
Filters each non-comment part through a callable.
const REGEX_IMPORTS_NO_URLS
static filterImports($content, $callback, $includeUrl=true)
Filters all CSS imports through a callable.
Create styles array
The data for the language used.
static filterIEFilters($content, $callback)
Filters all IE filters (AlphaImageLoader filter) through a callable.
static filterReferences($content, $callback)
Filters all references – url() and "@import" – through a callable.