You are here

function _module_builder_get_hook_file_urls in Module Builder 6.2

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

Get list of hook file URLS from any modules that declare them.

Return value

An array of data about the files to download, keyed by (safe) filename: [system.core.php] => Array [path] => the full path this file should be saved to [url] => URL [destination] => %module.module [group] => core

1 call to _module_builder_get_hook_file_urls()
module_builder_update_documentation in includes/update.inc
Updates hook documentation files.

File

includes/update.inc, line 88
Module builder file downloading.

Code

function _module_builder_get_hook_file_urls() {

  // Get data by invoking our hook.
  $data = _module_builder_invoke_hook();
  foreach ($data as $module => $module_data) {
    $branch = $module_data['branch'];
    foreach ($module_data['hook_files'] as $hook_file => $destination) {
      $url = str_replace(array(
        '%file',
        '%branch',
      ), array(
        $hook_file,
        $branch,
      ), $module_data['url']);

      // Create our own safe filename with module prefix.
      $hook_file_safe_name = "{$module}.{$hook_file}";
      $directory = _module_builder_get_hooks_directory();
      $urls[$hook_file_safe_name]['path'] = $directory . '/' . $hook_file_safe_name;
      $urls[$hook_file_safe_name]['url'] = $url;
      $urls[$hook_file_safe_name]['destination'] = $destination;
      if (isset($module_data['hook_destinations'])) {
        $urls[$hook_file_safe_name]['hook_destinations'] = array();
        foreach ($module_data['hook_destinations'] as $destination => $hooks) {
          $urls[$hook_file_safe_name]['hook_destinations'] += array_fill_keys($hooks, $destination);
        }
      }
      if ($module_data['group'] == '#filenames') {
        $urls[$hook_file_safe_name]['group'] = str_replace('.php', '', $hook_file);
      }
      else {
        $urls[$hook_file_safe_name]['group'] = $module_data['group'];
      }
    }
  }

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