function variable_static in Variable 7.2
Same name and namespace in other branches
- 6 variable.module \variable_static()
- 7 variable.module \variable_static()
Get variable info static data, try the cache, or invoke the hook to collect it.
Parameters
$type: Name of the info to collect
- 'variable', Variable information, hook_variable_info()
- 'group', Group information, hook_variable_group_info()
- 'type', Type information, hook_variable_type_info()
$options: Options to retrieve or build the data. The only used option to collect the data is 'langcode', though a full array of options may be used for the hooks
1 call to variable_static()
- _variable_info in ./
variable.module - Get data from a variable module info array.
File
- ./
variable.module, line 572 - Variable API module
Code
function &variable_static($type, $options = array()) {
static $data;
$name = 'variable_' . $type;
$langcode = isset($options['langcode']) ? $options['langcode'] : 'default';
if (!isset($data[$type])) {
$data[$type] =& drupal_static($name);
}
if (!isset($data[$type][$langcode])) {
$cache_id = $type . ':' . $langcode;
if ($cache = cache_get($cache_id, 'cache_variable')) {
$data[$type][$langcode] = $cache->data;
}
else {
variable_include();
$data[$type][$langcode] = variable_build_info($type, $options);
cache_set($cache_id, $data[$type][$langcode], 'cache_variable');
}
}
// Return a reference inside the big array
return $data[$type][$langcode];
}