public function Vars::getLibraryPath in Variable API 6.2
Same name and namespace in other branches
- 7.2 vars.classes.inc \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.module, line 159 - Implement an API to handle persistent variables.
Class
- Vars
- @file Implement an API to handle persistent variables.
Code
public function getLibraryPath($library, array $options = array()) {
global $profile;
$config = conf_path();
$id = preg_replace('/[^a-z0-9_]/i', '_', $library);
$path =& self::staticValue("vars_library_path_{$id}", array());
if ($path) {
return $path;
}
if (!isset($profile)) {
$profile = $this
->offsetGet('install_profile');
}
$dirs = array(
"profiles/{$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('vars_library_search_directories', $dirs, $context);
drupal_alter("vars_library_{$id}_search_directories", $dirs, $context);
foreach ($dirs as $dir) {
if (_var_check_locale_directory($dir, $context['files'])) {
$path[] = $dir;
}
}
return $path;
}