| Versionen | |
|---|---|
| drupal7 | _registry_get_resource_name(&$tokens = NULL, $type = NULL) |
Derive the name of the next resource in the token stream.
When called without arguments, it resets its static cache.
$tokens The collection of tokens for the current file being parsed.
$type The human-readable token name, either: "function", "class", or "interface".
The name of the resource, or FALSE if the resource has already been processed.
includes/
<?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.
$resources = &drupal_static(__FUNCTION__);
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;
}
?>
Kommentare
Kommentar hinzufügen