function _registry_parse_file in Drupal 7
Parse a file and save its interface 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 changed files and save their interface and class listings.
File
- includes/
registry.inc, line 191 - 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|trait)\\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();
}
}