You are here

function _module_builder_invoke_hook in Module Builder 6.2

Same name and namespace in other branches
  1. 7 includes/common.inc \_module_builder_invoke_hook()

Helper function to invoke hook_module_builder_info() in all modules.

The tricky part is that we want to include ourselves, but module_builder might not be installed (or even present) in Drupal if we are on Drush.

2 calls to _module_builder_invoke_hook()
_module_builder_get_hook_destinations in includes/update_7.inc
Add extra data about hook destinations to the hook file data. This allows entire files or individual hooks to have a file other than the default %module.module as their destination.
_module_builder_get_hook_file_urls in includes/update.inc
Get list of hook file URLS from any modules that declare them.

File

includes/common.inc, line 265
common.inc Stuff needed both by module and drush command.

Code

function _module_builder_invoke_hook() {

  // TODO: just get ours if no bootstrap?
  module_builder_include('common_version');
  $mb_files = module_builder_system_listing('\\.module_builder.inc$', 'modules');

  //print_r($mb_files);
  $module_data = array();
  foreach ($mb_files as $file) {

    // Our system listing wrapper ensured that there is a uri property on all versions.
    include_once $file->uri;

    // Use a property of the (badly-documented!) $file object that is common to both D6 and D7.
    $module = str_replace('.module_builder', '', $file->name);

    // Note that bad data got back from the hook breaks things.
    if ($result = module_invoke($module, 'module_builder_info')) {
      $module_data = array_merge($module_data, $result);
    }
  }

  //print_r($module_data);

  // If we are running as Drush command, we're not an installed module.
  if (!module_exists('module_builder')) {
    include_once dirname(__FILE__) . '/../module_builder.module_builder.inc';
    $data = array_merge($module_data, module_builder_module_builder_info());
  }
  else {
    $data = $module_data;

    // Yeah we switch names so the merging above isn't affected by an empty array.
    // Gah PHP. Am probably doin it wrong.
  }

  //print_r($data);
  return $data;
}