function _module_builder_get_hooks_directory in Module Builder 7
Same name and namespace in other branches
- 6.2 includes/common.inc \_module_builder_get_hooks_directory()
Get a directory to save or read hook data files.
This is either the variable from Drupal, or the --data option. Use of the --data option allows a central store of hook data that needs only be downloaded once for all Drupal sites. Subdirectories are made for each version.
This needs to be safe to use at any bootstrap level.
Return value
A directory path either relative to Drupal root or absolute.
11 calls to _module_builder_get_hooks_directory()
- module_builder_admin_update in includes/
module_builder.admin.inc - Admin hook update form.
- module_builder_callback_hook_download in drush/
module_builder.drush.inc - Callback for downloading hook data.
- module_builder_callback_hook_list in drush/
module_builder.drush.inc - Callback to list known hooks.
- module_builder_get_doc_files in includes/
process.inc - Retrieve list of documentation files containing hook definitions.
- module_builder_get_hook_data in includes/
process.inc - Retrieve hook data from storage file.
File
- includes/
common.inc, line 164 - common.inc Stuff needed both by module and drush command.
Code
function _module_builder_get_hooks_directory() {
$common = FALSE;
// Figure out the directory we should be using.
if (MODULE_BUILDER_ENV == 'drupal') {
// Running in a Drupal UI: directory is either 'hooks' or whatever the
// variable is set to.
$directory = variable_get('module_builder_hooks_directory', 'hooks');
}
else {
// TODO: TIDY UP!
// Running under Drush.
// The order is:
// - command --data option
// - local Drupal variable
// - default Drupal location in files/hooks
if (drush_get_option('data')) {
$directory = drush_get_option('data');
$common = TRUE;
}
if (!$directory) {
if (function_exists('variable_get')) {
// We're in a loaded Drupal, but MB might not be installed here.
$directory = variable_get('module_builder_hooks_directory', 'hooks');
// No variable: but could still be running MB, so we want files/hooks
if (!$directory) {
if (module_exists('module_builder')) {
$directory = 'hooks';
}
}
}
}
}
if (!$directory) {
// @todo: error!
}
// Check and create the directory if necessary: version-specific code.
module_builder_include('common_version');
module_builder_create_directory($directory, $common);
return $directory;
}