You are here

function module_builder_update_documentation in Module Builder 7

Same name in this branch
  1. 7 includes/update.inc \module_builder_update_documentation()
  2. 7 includes/update_7.inc \module_builder_update_documentation()
Same name and namespace in other branches
  1. 5 module_builder.module \module_builder_update_documentation()
  2. 6.2 includes/update.inc \module_builder_update_documentation()
  3. 6.2 includes/update_7.inc \module_builder_update_documentation()

Updates hook documentation files.

This function should be called after all settings have been checked. It ensures hook documentation files are available (on Drupal 5 and 6 by downloading them).

After calling this function, you probably want to pass the returned list of files to module_builder_process_hook_data(). Though really, instead of this function you probably want module_builder_update_data(). Just saying.

Return value

Array of hook files suitable for passing to module_builder_process_hook_data(). See file documentation for details.

1 call to module_builder_update_documentation()
module_builder_update_data in includes/common.inc
Update hook files and process them to our data file.

File

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

Code

function module_builder_update_documentation() {
  $directory = _module_builder_get_hooks_directory();

  //print_r($directory);

  // Fetch data about the files we need to download.
  $hook_files = _module_builder_get_hook_file_urls();

  //print_r($hook_files);

  // For testing only: skip downloading, just process.

  /*
  module_builder_process_hook_data($hook_files);
  return $hook_files;
  */

  // Retrieve each file and store it in the hooks directory, overwriting what's currently there
  foreach ($hook_files as $file_name => $data) {
    $file_contents = drupal_http_request($data['url']);
    _module_builder_drush_print("writing {$directory}/{$file_name}", 2);
    file_put_contents("{$directory}/{$file_name}", $destination . $file_contents->data);
  }

  // inform that hook documentation has been downloaded.
  drupal_set_message(t("Module Builder has just downloaded hook documentation to your %dir directory from CVS. This documentation contains detailed descriptions and usage examples of each of Drupal's hooks. Please view the files for more information, or view them online at the <a href=\"!api\">Drupal API documentation</a> site.", array(
    '%dir' => 'files/' . variable_get('module_builder_hooks_directory', 'hooks'),
    '!api' => url('http://api.drupal.org/'),
  )));
  return $hook_files;
}