_registry_parse_file

Versions
7
_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

▾ 1 function calls _registry_parse_file()

_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.

Code

includes/registry.inc, line 161

<?php
function _registry_parse_file($filename, $contents, $module = '', $weight = 0) {
  static $map = array(T_CLASS => 'class', T_INTERFACE => 'interface');
  // Delete registry entries for this file, so we can insert the new resources.
  db_delete('registry')
    ->condition('filename', $filename)
    ->execute();
  if (preg_match_all('/^\s*(?:abstract)?\s*(class|interface)\s+([a-zA-Z0-9_]+)/m', $contents, $matches)) {
    $query = db_insert('registry')->fields(array('name', 'type', 'filename', 'module', 'weight'));
    foreach ($matches[2] as $key => $name) {
      $query->values(array(
        'name' => $name,
        'type' => $matches[1][$key],
        'filename' => $filename,
        'module' => $module,
        'weight' => $weight,
      ));
    }
    $query->execute();
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.