function emapi_static in Embedded Media Field 6.3
Backport of d7's drupal_static().
3 calls to emapi_static()
- emapi_media_delete in emapi/
emapi.module - Delete a media object from the database.
- emapi_media_from_uri in emapi/
emapi.module - Loads a media object based on the given URI.
- emapi_media_load_multiple in emapi/
emapi.module - Load one or more fully populated media objects.
File
- emapi/
emapi.module, line 388 - Provides an API for parsing, storage, and display of third party media.
Code
function &emapi_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];
}