_registry_get_resource_name

Definition

_registry_get_resource_name(&$tokens = NULL, $type = NULL)
includes/registry.inc, line 202

Description

Derive the name of the next resource in the token stream.

When called without arguments, it resets its static cache.

Parameters

$tokens The collection of tokens for the current file being parsed.

$type The human-readable token name, either: "function", "class", or "interface".

Return value

The name of the resource, or FALSE if the resource has already been processed.

Related topics

Namesort iconDescription
Code registryThe code registry engine.

Code

<?php
function _registry_get_resource_name(&$tokens = NULL, $type = NULL) {
  // Keep a running list of all resources we've saved so far, so that we never
  // save one more than once.
  static $resources;

  if (!isset($tokens)) {
    $resources = array();
    return;
  }
  // Determine the name of the resource.
  next($tokens); // Eat a space.
  $token = next($tokens);
  if ($token == '&') {
    $token = next($tokens);
  }
  $resource_name = $token[1];

  // Ensure that we never save it more than once.
  if (isset($resources[$type][$resource_name])) {
    return FALSE;
  }
  $resources[$type][$resource_name] = TRUE;

  return $resource_name;
}
?>
 
 

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.