function messaging_static in Messaging 6.3
Same name and namespace in other branches
- 6.4 messaging.module \messaging_static()
Central static variable storage, Drupal 7 core backport
See http://api.drupal.org/api/function/drupal_static/7
6 calls to messaging_static()
- Messaging_API_Tests::testMessagingBasicAPI in tests/
messaging_api.test - Exercise basic API functions
- messaging_load_user in ./
messaging.module - Helper user loading function with static caching
- messaging_message_group in ./
messaging.module - Returns information about message groups
- messaging_message_load in ./
messaging.module - Helper function for message loading from the store
- messaging_method_info in ./
messaging.module - Returns messaging methods properties
File
- ./
messaging.module, line 1189
Code
function &messaging_static($name, $default_value = NULL, $reset = FALSE) {
static $data = array(), $default = array();
if (!isset($name)) {
// All variables are reset. This needs to be done one at a time so that
// references returned by earlier invocations of drupal_static() also get
// reset.
foreach ($default as $name => $value) {
$data[$name] = $value;
}
// As the function returns a reference, the return should always be a
// variable.
return $data;
}
if ($reset) {
// The reset means the default is loaded.
if (array_key_exists($name, $default)) {
$data[$name] = $default[$name];
}
else {
// Reset was called before a default is set and yet a variable must be
// returned.
return $data;
}
}
elseif (!array_key_exists($name, $data)) {
// Store the default value internally and also copy it to the reference to
// be returned.
$default[$name] = $data[$name] = $default_value;
}
return $data[$name];
}