function _registry_parse_file

7 registry.inc _registry_parse_file($filename, $contents, $module = '', $weight = 0)

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

2 calls to _registry_parse_file()
RegistryParseFileTestCase::testRegistryParseFile in modules/simpletest/tests/registry.test
testRegistryParseFile
_registry_parse_files in includes/registry.inc
Parse all files that have changed since the registry was last built, and save their function and class listings.

File

includes/registry.inc, line 163
This file contains the code registry parser engine.

Code

function _registry_parse_file($filename, $contents, $module = '', $weight = 0) {
  if (preg_match_all('/^\s*(?:abstract|final)?\s*(class|interface)\s+([a-zA-Z0-9_]+)/m', $contents, $matches)) {
    foreach ($matches[2] as $key => $name) {
      db_merge('registry')->key(array(
        'name' => $name,
        'type' => $matches[1][$key],
      ))->fields(array(
        'filename' => $filename,
        'module' => $module,
        'weight' => $weight,
      ))->execute();
    }
    // Delete any resources for this file where the name is not in the list
    // we just merged in.
    db_delete('registry')->condition('filename', $filename)->condition('name', $matches[2], 'NOT IN')->execute();
  }
}