function libraries_cdn_cron in Libraries CDN API 7
Implements hook_cron().
File
- ./
libraries_cdn.module, line 120 - Main module file.
Code
function libraries_cdn_cron() {
$libraries = libraries_info();
foreach ($libraries as $library_name => $library) {
if (isset($library['cdn'])) {
$options = $library['cdn'];
if (!isset($options['options'])) {
$options['options'] = array();
}
// @codingStandardsIgnoreStart
$available_plugins = \Drupal\libraries_cdn\LibrariesCDN::getAvailableCDN();
// @codingStandardsIgnoreEnd
if (!isset($options['plugins']) || empty($options['plugins'])) {
$options['plugins'] = $available_plugins;
}
else {
$options['plugins'] = array_filter($options['filter'], function ($value) use ($available_plugins) {
return in_array($value, $available_plugins);
});
}
if (!isset($options['aliases'])) {
$options['aliases'] = array();
}
$options['aliases'] += array(
$library_name,
);
$options['aliases'] = array_unique($options['aliases']);
foreach ($options['aliases'] as $alias) {
foreach ($options['plugins'] as $plugin) {
// @codingStandardsIgnoreStart
\Drupal\libraries_cdn\LibrariesCDN::setPlugin($plugin, $alias, $options);
\Drupal\libraries_cdn\LibrariesCDN::getLocalLibrariesVariants($library);
// @codingStandardsIgnoreEnd
}
}
}
}
}