1. drupal
    1. 8
    2. 7
7 – 8 hook_registry_files_alter(&$files, $modules)

Perform necessary alterations to the list of files parsed by the registry.

Modules can manually modify the list of files before the registry parses them. The $modules array provides the .info file information, which includes the list of files registered to each module. Any files in the list can then be added to the list of files that the registry will parse, or modify attributes of a file.

A necessary alteration made by the core SimpleTest module is to force .test files provided by disabled modules into the list of files parsed by the registry.


$files List of files to be parsed by the registry. The list will contain files found in each enabled module's info file and the core includes directory. The array is keyed by the file path and contains an array of the related module's name and weight as used internally by _registry_update() and related functions.

For example:

    $files["modules/system/system.module"] = array(
      'module' => 'system',
      'weight' => 0,

$modules An array containing all module information stored in the {system} table. Each element of the array also contains the module's .info file information in the property 'info'. An additional 'dir' property has been added to the module information which provides the path to the directory in which the module resides. The example shows how to take advantage of both properties.

See also



Related topics


modules/system/system.api.php, line 3388

function hook_registry_files_alter(&$files, $modules) {
  foreach ($modules as $module) {
    // Only add test files for disabled modules, as enabled modules should
    // already include any test files they provide.
    if (!$module->status) {
      $dir = $module->dir;
      foreach ($module->info['files'] as $file) {
        if (substr($file, -5) == '.test') {
          $files["$dir/$file"] = array(
            'module' => $module->name,
            'weight' => $module->weight,