function ctools_static in Chaos Tool Suite (ctools) 6
Central static variable storage. Modeled after Drupal 7's drupal_static().
Parameters
$name: Globally unique name for the variable. For a function with only one static, variable, the function name (e.g. via the PHP magic __FUNCTION__ constant) is recommended. For a function with multiple static variables add a distinguishing suffix to the function name for each one.
$default_value: Optional default value.
$reset: TRUE to reset a specific named variable, or all variables if $name is NULL. Resetting every variable should only be used, for example, for running unit tests with a clean environment. Should be used only though via function ctools_static_reset().
16 calls to ctools_static()
- ctools_ajax_page_preprocess in includes/
ajax.inc - Implement hook_preprocess_page. Process variables for page.tpl.php
- ctools_ajax_run_page_preprocess in includes/
ajax.inc - Function that controls if ctools_ajax_page_preprocess() will run.
- ctools_ajax_set_verification_header in includes/
ajax.inc - Sets a response header for ajax.js to trust the response body.
- ctools_export_get_schema in includes/
export.inc - Get the schema for a given table.
- ctools_export_load_object in includes/
export.inc - Load some number of exportable objects.
File
- ./
ctools.module, line 185 - CTools primary module file.
Code
function &ctools_static($name, $default_value = NULL, $reset = FALSE) {
static $data = array();
// Reset a single value, or all values.
if ($reset) {
if (isset($name)) {
unset($data[$name]);
}
else {
$data = array();
}
// We must return a reference to a variable.
$dummy = NULL;
return $dummy;
}
if (!isset($data[$name])) {
$data[$name] = $default_value;
}
return $data[$name];
}