public function ProviderBase::getAssets in Express 8
Retrieves Provider assets for the active provider, if any.
Parameters
string|array $types: The type of asset to retrieve: "css" or "js", defaults to an array array containing both if not set.
Return value
array If $type is a string or an array with only one (1) item in it, the assets are returned as an indexed array of files. Otherwise, an associative array is returned keyed by the type.
Overrides ProviderInterface::getAssets
2 calls to ProviderBase::getAssets()
- Custom::getAssets in themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ Custom.php - Retrieves Provider assets for the active provider, if any.
- JsDelivr::getAssets in themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ JsDelivr.php - Retrieves Provider assets for the active provider, if any.
2 methods override ProviderBase::getAssets()
- Custom::getAssets in themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ Custom.php - Retrieves Provider assets for the active provider, if any.
- JsDelivr::getAssets in themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ JsDelivr.php - Retrieves Provider assets for the active provider, if any.
File
- themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ ProviderBase.php, line 47 - Contains \Drupal\bootstrap\Plugin\Provider\ProviderBase.
Class
- ProviderBase
- CDN provider base class.
Namespace
Drupal\bootstrap\Plugin\ProviderCode
public function getAssets($types = NULL) {
// Immediately return if there are no assets.
if (!$this->assets) {
return $this->assets;
}
$assets = [];
// If no type is set, return all CSS and JS.
if (!isset($types)) {
$types = [
'css',
'js',
];
}
$types = is_array($types) ? $types : [
$types,
];
// Ensure default arrays exist for the requested types.
foreach ($types as $type) {
$assets[$type] = [];
}
// Retrieve the system performance config.
$config = \Drupal::config('system.performance');
// Iterate over each type.
foreach ($types as $type) {
$min = $config
->get("{$type}.preprocess");
$files = $min && isset($this->assets['min'][$type]) ? $this->assets['min'][$type] : (isset($this->assets[$type]) ? $this->assets[$type] : []);
foreach ($files as $asset) {
$data = [
'data' => $asset,
'type' => 'external',
'weight' => -19.999,
];
// CSS library assets use "SMACSS" categorization, assign it to "base".
if ($type === 'css') {
$assets[$type]['base'][$asset] = $data;
}
else {
$assets[$type][$asset] = $data;
}
}
}
return count($types) === 1 ? $assets[$types[0]] : $assets;
}