Skip to content
Snippets Groups Projects
Commit 5aec5f81 authored by Dieter Holvoet's avatar Dieter Holvoet Committed by Lisa Harrison
Browse files

Issue #3371573 by roshni27, empesan, dpineda, DieterHolvoet, lhridley: Call to...

Issue #3371573 by roshni27, empesan, dpineda, DieterHolvoet, lhridley: Call to undefined function file_create_url() in CssOptimizer
parent afb21f06
No related branches found
No related tags found
3 merge requests!43Issue #3292158 by bbombachini, DieterHolvoet, hkirsman, Amanda95, alcalvo,...,!38Issue #3292158 by bbombachini, DieterHolvoet, hkirsman, Amanda95, alcalvo,...,!37Issue #3292158 by bbombachini, DieterHolvoet, hkirsman, Amanda95, alcalvo,...
......@@ -10,12 +10,29 @@ use Drupal\Core\Asset\CssOptimizer as DrupalCssOptimizer;
* @codeCoverageIgnore
*/
class CssOptimizer extends DrupalCssOptimizer {
/**
* The FileUrl Generator Service.
*
* @var \Drupal\Core\File\FileUrlGeneratorInterface
*/
protected $fileUrlGenerator;
/**
* Constructs a new CssOptimizer object.
*
* @param \Drupal\Core\File\FileUrlGeneratorInterface $fileUrlGenerator
* The FileUrl Generator service.
*/
public function __construct(FileUrlGeneratorInterface $fileUrlGenerator) {
parent::__construct($fileUrlGenerator);
$this->fileUrlGenerator = $fileUrlGenerator;
}
/**
* {@inheritdoc}
*/
// phpcs:ignore
public function rewriteFileURI($matches) {
public function rewriteFileURI($matches): string {
// Prefix with base and remove '../' segments where possible.
$path = $this->rewriteFileURIBasePath . $matches[1];
$last = '';
......@@ -23,9 +40,8 @@ class CssOptimizer extends DrupalCssOptimizer {
$last = $path;
$path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
}
// file_url_transform_relative() was removed here.
return 'url(' . \Drupal::service('file_url_generator')->generateAbsoluteString($path) . ')';
return 'url(' . $this->fileUrlGenerator->generate($path)?->toString() . ')';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment