You are here

function coder_upgrade_module_name in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_upgrade/includes/main.inc \coder_upgrade_module_name()

Adds the module name to the item array.

Parameters

string $dirname: A string of the directory name.

array $item: Array of a directory containing the files to convert.

2 calls to coder_upgrade_module_name()
coder_upgrade_cache_info_hooks in coder_upgrade/conversions/begin.inc
Caches hook_theme() and hook_menu() entries for the modules being converted.
coder_upgrade_convert_dir in coder_upgrade/includes/main.inc
Converts files in a directory.

File

coder_upgrade/includes/main.inc, line 528
Manages application of conversion routines, logging, and patch file creation.

Code

function coder_upgrade_module_name($dirname, &$item) {

  // Extensions that indicate a module is present.
  $extensions = array(
    'info',
    'module',
  );

  /*
   * Set the module name in case there is no module in the directory (e.g. po
   * or translations).
   *
   * This code assumes at most one module per directory. Absent this condition
   * we have no way of determining the file list for the .info file. This
   * condition does not hold for the devel project which has 4 modules in its
   * top-level directory.
   */
  $item['module'] = '';

  // Loop on files.
  $path = $dirname . '/';
  $files = scandir($path);
  foreach ($files as $file) {
    $file_path = $path . $file;
    if (!is_dir($file_path)) {
      if (in_array(pathinfo($file_path, PATHINFO_EXTENSION), $extensions)) {
        $item['module'] = pathinfo($file_path, PATHINFO_FILENAME);
        break;
      }
    }
  }
}