You are here

function variable_static in Variable 7.2

Same name and namespace in other branches
  1. 6 variable.module \variable_static()
  2. 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

$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];
}