Same name and namespace in other branches
- 6.0.x src/Asset/CssOptimizer.php \Drupal\advagg\Asset\CssOptimizer::fixType() 1 comment
- 8.x-3.x src/Asset/CssOptimizer.php \Drupal\advagg\Asset\CssOptimizer::fixType() 1 comment
- 8.x-4.x src/Asset/CssOptimizer.php \Drupal\advagg\Asset\CssOptimizer::fixType() 1 comment
Overrides AssetOptimizer::fixType
File
-
src/
Asset/ CssOptimizer.php, line 47
Class
- CssOptimizer
- The CSS Optimizer.
Namespace
Drupal\advagg\AssetCode
protected function fixType(array &$asset) {
// Default asset type to file if not set/invalid.
if (!in_array($asset['type'], [
'file',
'external',
'settings',
])) {
$asset['type'] = 'file';
}
$path = $asset['data'];
if ($asset['type'] === 'external') {
// If type is external but path doesn't start with http, https, or //
// change it to file.
if (stripos($path, 'http') !== 0 && stripos($path, '//') !== 0) {
$asset['type'] = 'file';
}
elseif (stripos($path, $this->basePath) !== FALSE && !$this->config
->get('css.preserve_external')) {
$asset['type'] = 'file';
$asset['group'] = CSS_BASE;
$asset['every_page'] = TRUE;
$asset['weight'] = -40000;
$asset['data'] = substr($asset['data'], stripos($asset['data'], $this->basePath) + $this->basePathLen);
}
}
elseif ($asset['type'] === 'file' && (stripos($path, 'http') === 0 || stripos($path, '//') === 0)) {
$asset['type'] = 'external';
}
}