function _acquia_lift_convert_libraries_to_library in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 acquia_lift.module \_acquia_lift_convert_libraries_to_library()
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 _acquia_lift_convert_libraries_to_library()
- acquia_lift_library in ./
acquia_lift.module - Implements hook_library().
File
- ./
acquia_lift.module, line 2041 - acquia_lift.module Provides Acquia Lift-specific personalization functionality.
Code
function _acquia_lift_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 = _acquia_lift_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;
}