class CssOptimizer in CDN 8.3
Decorates CSS asset optimizer: ensures file URLs are rewritten to the CDN.
Hierarchy
- class \Drupal\cdn\Asset\CssOptimizer implements AssetOptimizerInterface
Expanded class hierarchy of CssOptimizer
See also
https://www.drupal.org/node/2745109
1 string reference to 'CssOptimizer'
1 service uses CssOptimizer
File
- src/
Asset/ CssOptimizer.php, line 13
Namespace
Drupal\cdn\AssetView source
class CssOptimizer implements AssetOptimizerInterface {
/**
* The decorated CSS asset optimizer service.
*
* @var \Drupal\Core\Asset\AssetOptimizerInterface
*/
protected $decoratedCssOptimizer;
/**
* @param \Drupal\Core\Asset\AssetOptimizerInterface $decorated_css_optimizer
* The decorated CSS asset optimizer service.
*/
public function __construct(AssetOptimizerInterface $decorated_css_optimizer) {
$this->decoratedCssOptimizer = $decorated_css_optimizer;
}
/**
* {@inheritdoc}
*/
public function optimize(array $css_asset) {
return $this
->runWithoutCdnFileAlteration(function () use ($css_asset) {
return $this->decoratedCssOptimizer
->optimize($css_asset);
});
}
/**
* {@inheritdoc}
*/
public function clean($contents) {
return $this
->runWithoutCdnFileAlteration(function () use ($contents) {
return $this->decoratedCssOptimizer
->clean($contents);
});
}
/**
* Wraps callable in an environment where the global $cdn_in_css_file===FALSE.
*
* @param callable $callable
* A callable.
*
* @return mixed
* The result of the callable.
*/
protected function runWithoutCdnFileAlteration(callable $callable) {
global $_cdn_in_css_file;
$_cdn_in_css_file = TRUE;
$result = $callable();
$_cdn_in_css_file = FALSE;
return $result;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CssOptimizer:: |
protected | property | The decorated CSS asset optimizer service. | |
CssOptimizer:: |
public | function |
Removes unwanted content from an asset. Overrides AssetOptimizerInterface:: |
|
CssOptimizer:: |
public | function |
Optimizes an asset. Overrides AssetOptimizerInterface:: |
|
CssOptimizer:: |
protected | function | Wraps callable in an environment where the global $cdn_in_css_file===FALSE. | |
CssOptimizer:: |
public | function |