public function Vars::getLibraryPath in Variable API 7.2
Same name and namespace in other branches
- 6.2 vars.module \Vars::getLibraryPath()
Returns the list of the directories where library files are looked in.
Parameters
$library: The library to look for. This parameter will be used as directory name.
$options: An array of extra options.
Return value
An array of directories where the library can be found.
File
- ./
vars.classes.inc, line 171 - Classes implemented by the Variable API module.
Class
- Vars
- @file Classes implemented by the Variable API module.
Code
public function getLibraryPath($library, array $options = array()) {
$config = conf_path();
$id = preg_replace('/[^a-z0-9_]/i', '_', $library);
$path =& self::staticValue("vars_library_path_{$id}", array());
if ($path) {
return $path;
}
$dirs = array(
'profiles/' . drupal_get_profile() . "/libraries/{$library}",
"sites/all/libraries/{$library}",
"{$config}/libraries",
);
// Allow third-party modules to alter the list of directories where
// Variables API looks for the directory $library.
$context = array(
'library' => $library,
);
if (!empty($options['files'])) {
$context['files'] = is_array($options['files']) ? $options['files'] : array(
$options['files'],
);
}
else {
$context['files'] = array();
}
drupal_alter(array(
'vars_library_search_directories',
"vars_library_{$id}_search_directories",
), $dirs, $context);
foreach ($dirs as $dir) {
$function = preg_match('#^https?://#i', $dir) ? '_vars_check_remote_directory' : '_var_check_locale_directory';
if ($function($dir, $context['files'])) {
$path[] = $dir;
}
}
return $path;
}