public static function LibrariesCDN::getCDNLibrariesVariants in Libraries CDN API 7
Same name and namespace in other branches
- 8 src/LibrariesCdn.php \Drupal\libraries_cdn\LibrariesCdn::getCDNLibrariesVariants()
Generate an array for the variants of the Libraries API module.
These variants are from the CDN plugins only.
Parameters
array $library: The library array.
Return value
array The returned array can be applied to the 'variants' key in the library definition in hook_libraries_info().
1 call to LibrariesCDN::getCDNLibrariesVariants()
- LibrariesCDN::getLibrariesVariants in src/
LibrariesCDN.php - Generate an array for the variants of the Libraries API module.
File
- src/
LibrariesCDN.php, line 259 - Contains LibrariesCDN.
Class
- LibrariesCDN
- Class LibrariesCDN.
Namespace
Drupal\libraries_cdnCode
public static function getCDNLibrariesVariants(array &$library = array()) {
$variants = array();
$module_path = drupal_get_path('module', 'libraries_cdn');
$information = self::getInformation();
$configuration = self::$plugin
->getConfiguration();
$name = isset($information['name']) ? $information['name'] : self::getLibrary();
foreach (self::getFiles() as $version => $files) {
foreach ($files as $file) {
if (strpos($file, 'debug') !== FALSE || strpos($file, 'min') !== FALSE) {
continue;
}
$variant = self::$plugin
->getPluginId() . ':' . self::getLibrary() . ':' . $version;
$ext = pathinfo($file, PATHINFO_EXTENSION);
// Default CDN version.
$variants[$variant]['name'] = sprintf("%s %s", $name, $version);
$variants[$variant]['library path'] = $module_path;
$variants[$variant]['files'][$ext][$file] = array(
'type' => 'external',
'data' => $file,
) + (array) self::$plugin
->getConfiguration('options');
}
}
if (isset($configuration['limit']) && is_int(intval($configuration['limit'])) && $configuration['limit'] > 0) {
$variants = array_slice($variants, 0, $configuration['limit']);
}
return $variants;
}