You are here

function module_builder_include in Module Builder 7

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

Include a version-specific file whether we're on drush or drupal. That is, we first try to include a file called NAME_X.inc where X is a Drupal major version number before falling back to NAME.inc.

Files are included from the 'includes' folder inside module_builder.

On Drush, this is a wrapper for drush_include(). On Drupal, this just goes straight for the current version.

Parameters

$name: The filename, eg 'update'.

$extension: The file extension.

13 calls to module_builder_include()
module_builder_admin_update in includes/module_builder.admin.inc
Admin hook update form.
module_builder_callback_build in drush/module_builder.drush.inc
Module builder drush command callback.
module_builder_callback_doc_hooks in drush/module_builder.drush.inc
Callback to add doc headers to existing hooks.
module_builder_callback_doc_params in drush/module_builder.drush.inc
WORK IN PROGRESS Add function headers wherever needed with params.
module_builder_callback_hook_list in drush/module_builder.drush.inc
Callback to list known hooks.

... See full list

File

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

Code

function module_builder_include($name, $extension = 'inc') {
  $path = module_builder_get_path('includes');
  if (MODULE_BUILDER_ENV == 'drush') {

    // In Drush.
    // the NULL means drush_include will try to find the version.
    drush_include($path, $name, NULL, $extension);
  }
  else {

    // In Drupal GUI.
    // Try the versioned file first.
    $file = sprintf("%s/%s_%s.%s", $path, $name, _module_builder_drupal_major_version(), $extension);

    //dsm($file);
    if (file_exists($file)) {
      require_once $file;
      return;
    }

    // Fall back to the regular file.
    $file = sprintf("%s/%s.%s", $path, $name, $extension);
    require_once $file;
  }
}