You are here

function _autoload_registry_parse_files in Autoload 6.2

Parse a file and save its function and class listings.

Parameters

$filename: Name of the file we are going to parse.

$contents: Contents of the file we are going to parse as a string.

$module: (optional) Name of the module this file belongs to.

$weight: (optional) Weight of the module.

Related topics

1 call to _autoload_registry_parse_files()
_autoload_registry_update in ./autoload.registry.inc
Does the work for autoload_registry_update().

File

./autoload.registry.inc, line 165
This file contains the code registry parser engine. This file is backported from Drupal 7 core's registry.inc file.

Code

function _autoload_registry_parse_files($files) {
  $parsed_files = array();
  foreach ($files as $filename => $file) {
    if (file_exists($filename)) {
      $hash = hash_file('sha256', $filename);
      if (empty($file['hash']) || $file['hash'] != $hash) {

        // Delete registry entries for this file, so we can insert the new resources.
        db_query("DELETE FROM {autoload_registry} WHERE filename = '%s'", $filename);
        $file['hash'] = $hash;
        $parsed_files[$filename] = $file;
      }
    }
  }
  foreach ($parsed_files as $filename => $file) {
    _autoload_registry_parse_file($filename, file_get_contents($filename), $file['module'], $file['weight']);
    db_query("UPDATE {autoload_registry_file} SET hash = '%s' WHERE filename = '%s'", $file['hash'], $filename);
    if (!db_affected_rows()) {
      db_query("INSERT INTO {autoload_registry_file} (filename, hash) VALUES ('%s', '%s')", $filename, $file['hash']);
    }
  }
  return array_keys($parsed_files);
}