function _fullcalendar_view_use_cdn_full_path in Fullcalendar View 6.x
Same name and namespace in other branches
- 5.x fullcalendar_view.module \_fullcalendar_view_use_cdn_full_path()
Replace local rrule library with CDN.
Parameters
array $libraries: The libraries array.
string $library_name: The library name.
string $type: The library type.
bool $replace_local: Force to replace local libraries with CDN.
Return value
array The new library array (CDN)
1 call to _fullcalendar_view_use_cdn_full_path()
- fullcalendar_view_library_info_alter in ./
fullcalendar_view.module - Implements hook_library_info_alter().
File
- ./
fullcalendar_view.module, line 150 - Full Canlendar Views module help and theme functions.
Code
function _fullcalendar_view_use_cdn_full_path(array $libraries, $library_name, $type, $replace_local = FALSE) {
if (isset($libraries[$library_name])) {
if (isset($libraries[$library_name][$type]) && isset($libraries[$library_name]['cdn'])) {
$library_array = [];
$updated = FALSE;
// CSS library has a sub-array called component.
if ($type === 'css') {
if (isset($libraries[$library_name][$type]['component'])) {
$local_library = $libraries[$library_name][$type]['component'];
}
else {
return FALSE;
}
}
else {
// Local js library.
$local_library = $libraries[$library_name][$type];
}
foreach ($local_library as $key => $value) {
if (!file_exists(DRUPAL_ROOT . $key) || $replace_local) {
// The js file doesn't exist.
// Replace it with remote cdn.
$library_array[$libraries[$library_name]['cdn']] = $value;
$updated = TRUE;
}
else {
$library_array[$key] = $value;
}
}
}
}
return empty($updated) ? FALSE : $library_array;
}