This project is not covered by Drupal’s security advisory policy.

Registry is a developer API only. This module has no end-user functionality.

The registry is a key-value store which loads on each request and contains information about the request and other context. It allows modules to set and request information along the execution chain.

The registry is only for aggregating information about the current request, and is not used for storing information across requests (for this, use Drupal's variable functions, or consider the Object Cache module).

Some things you might be able to do with the Registry

  • React to request information
  • Access node information outside the node object (for example, in a block)
  • Set a context for other modules to react to
  • Avoid global $var
  • Never call arg(1) again!

Features

Registry currently loads the following:

  • Basic request information (args, path)
  • The current node, if on a node path
  • The current user

Wish something else was there? Just write a module...

API

Access the registry (PHP 5.3)
This allows you to then act on the returned registry

registry();
// e.g.
registry()->set($key, $value);

Access the registry (PHP 5.2)

$registry = registry_invoke();

Functional wrappers are also provided to work with the registry object. Using the wrappers ensures that the registry functions correctly. The two important ones are the get and set functions, which work in a similar manner to Drupal's variable get and set functions

Set a registry value
This function expects a string key, however the value can be anything.

registry_set($key, $value, $protected = FALSE);

Set a registry value using a callback
This can be used to return registry values when they are called, rather than when they are set.

registry_set_callback($key, $callback, $args = NULL, $protected = FALSE);

Setting by reference is generally discouraged, however you can set directly using a more verbose method, which also also allows passing in objects by reference, for example.

$registry = &registry_invoke();
$registry->$key['#value'] =& $value;

Access a registry value

registry_get($key);

Delete a registry value

registry_delete($key);

Project information

Releases