public function CssOptimizer::rewriteFileURI
public CssOptimizer::rewriteFileURI($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.
Parameters
array $matches: An array of matches by a preg_replace_callback() call that scans for url() references in CSS files, except for external or absolute ones.
Return value
string The file path.
File
- core/lib/Drupal/Core/Asset/CssOptimizer.php, line 250
Class
- CssOptimizer
- Optimizes a CSS asset.
Namespace
Drupal\Core\AssetCode
public function rewriteFileURI($matches) { // Prefix with base and remove '../' segments where possible. $path = $this->rewriteFileURIBasePath . $matches[1]; $last = ''; while ($path != $last) { $last = $path; $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path); } return 'url(' . file_url_transform_relative(file_create_url($path)) . ')'; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Asset!CssOptimizer.php/function/CssOptimizer::rewriteFileURI/8.1.x