Same name in other branches
- 5.0.x src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::processAssetArray()
- 6.0.x src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::processAssetArray()
- 8.x-4.x src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::processAssetArray()
Process a core asset array.
Paramètres
array $assets: The core asset array (css or js) to process.
Fichier
-
src/
Asset/ AssetOptimizer.php, line 127
Classe
- AssetOptimizer
- Defines the base AdvAgg optimizer.
Namespace
Drupal\advagg\AssetCode
public function processAssetArray(array &$assets) {
$protocol_relative = $this->config
->get('path.convert.absolute_to_protocol_relative');
$force_https = $this->config
->get('path.convert.force_https');
foreach ($assets as &$asset) {
if (!is_string($asset['data'])) {
continue;
}
// Fix type if it was incorrectly set.
if ($this->fixType) {
$this->fixType($asset);
}
if ($asset['type'] === 'file' && $asset['preprocess']) {
if (!is_readable($asset['data'])) {
continue;
}
$this->scanFile($asset);
}
elseif ($asset['type'] === 'external') {
if ($force_https) {
$asset['data'] = $this->convertPathForceHttps($asset['data']);
}
elseif ($protocol_relative) {
$asset['data'] = $this->convertPathProtocolRelative($asset['data']);
}
$scheme = parse_url($asset['data'], PHP_URL_SCHEME);
$host = parse_url($asset['data'], PHP_URL_HOST);
$asset_url = isset($scheme) ? "{$scheme}://{$host}" : "//{$host}";
$this->dnsPrefetch[] = $asset_url;
}
}
if (!isset($GLOBALS['_advagg_prefetch'])) {
$GLOBALS['_advagg_prefetch'] = [];
}
$GLOBALS['_advagg_prefetch'] += $this->dnsPrefetch;
}