function _quickedit_convert_libraries_to_library in Quick Edit 7
Converts a libraries module array to a hook_library array.
@todo Libraries API should automatically register all libraries in hook_library(). See https://drupal.org/node/1386368
Return value
Array Returns a standard Drupal library definition structure.
1 call to _quickedit_convert_libraries_to_library()
- quickedit_library in ./
quickedit.module - Implements hook_library().
File
- includes/
libraries.inc, line 96 - Logic to nicely integrate with Libraries API.
Code
function _quickedit_convert_libraries_to_library($library, $options = array()) {
// If the library wasn't installed, don't bother converting it.
if (!$library['installed']) {
return array();
}
$converted = array();
$files = array();
// Get the library files from one of the installed variants.
if ($name = _quickedit_libraries_get_preferred_variant_name($library)) {
$files = $library['variants'][$name]['files'];
}
// Define the library if files exist for it.
if (!empty($files)) {
// This is the basic structure expected by hook_library().
$converted = array(
'title' => $library['name'],
'website' => $library['vendor url'],
'version' => $library['version'],
);
foreach ($files as $type => $paths) {
foreach ($paths as $filename => $data) {
$converted[$type][$library['library path'] . '/' . $filename] = $options;
}
}
}
return $converted;
}