You are here

function _module_builder_get_hook_destinations in Module Builder 7

Same name and namespace in other branches
  1. 6.2 includes/update_7.inc \_module_builder_get_hook_destinations()

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.

1 call to _module_builder_get_hook_destinations()
module_builder_update_documentation in includes/update_7.inc
Updates hook documentation files.

File

includes/update_7.inc, line 99
Module builder: get list of hook files for Drupal 7.

Code

function _module_builder_get_hook_destinations(&$hook_files) {

  // Get data by invoking our hook.
  $data = _module_builder_invoke_hook();

  // Incoming data is destination key, array of hooks.
  // (Because it makes typing the data out easier! Computers can just adapt.)
  foreach ($data as $module => $module_data) {

    // The key in $hook_files we correspond to
    // @todo, possibly: this feels like slightly shaky ground.
    $filename = "{$module}.api.php";
    if (isset($module_data['destination'])) {
      $hook_files[$filename]['destination'] = $module_data['destination'];
    }
    if (isset($module_data['hook_destinations'])) {
      foreach ($module_data['hook_destinations'] as $destination => $hooks) {
        $destinations[$module] = array_fill_keys($hooks, $destination);
        $hook_files[$filename]['hook_destinations'] = array();
        $hook_files[$filename]['hook_destinations'] += array_fill_keys($hooks, $destination);
      }
    }
  }

  //print_r($hook_files);
}