protected function JsDelivr::extractThemes in Express 8
Extracts theme information from files provided by the jsDelivr API.
This will place the raw files into proper "css", "js" and "min" arrays (if they exist) and prepends them with a base URL provided.
Parameters
array $files: An array of files to process.
string $base_url: The base URL each one of the $files are relative to, this usually should also include the version path prefix as well.
Return value
array An associative array containing the following keys, if there were matching files found:
- css
- js
- min:
- css
- js
1 call to JsDelivr::extractThemes()
- JsDelivr::processApi in themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ JsDelivr.php - Processes the provider plugin definition upon discovery.
File
- themes/
contrib/ bootstrap/ src/ Plugin/ Provider/ JsDelivr.php, line 50 - Contains \Drupal\bootstrap\Plugin\Provider\JsDelivr.
Class
- JsDelivr
- The "jsdelivr" CDN provider plugin.
Namespace
Drupal\bootstrap\Plugin\ProviderCode
protected function extractThemes(array $files, $base_url = '') {
$themes = [];
foreach ($files as $file) {
preg_match('`([^/]*)/bootstrap(-theme)?(\\.min)?\\.(js|css)$`', $file, $matches);
if (!empty($matches[1]) && !empty($matches[4])) {
$path = $matches[1];
$min = $matches[3];
$filetype = $matches[4];
// Determine the "theme" name.
if ($path === 'css' || $path === 'js') {
$theme = 'bootstrap';
$title = (string) t('Bootstrap');
}
else {
$theme = $path;
$title = ucfirst($path);
}
if ($matches[2]) {
$theme = 'bootstrap_theme';
$title = (string) t('Bootstrap Theme');
}
$themes[$theme]['title'] = $title;
if ($min) {
$themes[$theme]['min'][$filetype][] = "{$base_url}/{$path}/bootstrap{$matches[2]}{$min}.{$filetype}";
}
else {
$themes[$theme][$filetype][] = "{$base_url}/{$path}/bootstrap{$matches[2]}{$min}.{$filetype}";
}
}
}
return $themes;
}