You are here

public function RegistryAutoloadSearcher::processFiles in Registry Autoload 7

Processes files containing classes for the given module.

Parameters

array $class_files: The files to scan for classes.

object $module: The module object as given to hook_registry_files_alter().

Return value

array An associative array keyed by filename with object values. The objects have the following properties:

  • classes: An associative array keyed by namespace+name with properties:

    • type: Type of the class, can be 'interface' or 'class'.
    • name: Name of the class or interface.

    This can be empty if needs_update below is FALSE.

  • filename: The filename of the file.
  • module: The module this file belongs to.
  • weight: The weight of the module this file belongs to.
  • hash: The file_hash() of the filename.
  • needs_update: Whether the registry needs to be updated or not.

File

./registry_autoload.module, line 221
Main module for enabling core registry to support namespaced files.

Class

RegistryAutoloadSearcher
RegistryAutoloadSearcher helper class.

Code

public function processFiles(array $class_files, $module) {
  $registry = array();
  foreach ($class_files as $filename) {

    // Check if file exists.
    if (!file_exists($filename)) {
      continue;
    }
    $hash = NULL;
    $needs_update = $this
      ->checkFileNeedsUpdate($filename, $hash);
    $registry[$filename] = (object) array(
      'classes' => array(),
      'filename' => $filename,
      'module' => $module->name,
      'weight' => $module->weight,
      // We create a unique structure to populate both registry tables.
      'hash' => $hash,
      'needs_update' => $needs_update,
    );
    if ($needs_update) {
      $this
        ->parseFile($registry[$filename], $filename);
    }
  }
  return $registry;
}