You are here

function variable_get_value in Variable 7.2

Same name and namespace in other branches
  1. 6 variable.module \variable_get_value()
  2. 7 variable.module \variable_get_value()

Get value for simple scalar variable

Parameters

$variable: Variable name or array data

$options: Options array, it may have the following elements

  • language => Language object
  • default => Default value if not set
  • realm => Realm object if working inside a variable realm

Related topics

9 calls to variable_get_value()
VariableStoreTestCase::testVariableStoreAPI in variable_store/variable_store.test
Test that all core modules can be enabled, disabled and uninstalled.
VariableTestCase::testVariableAPI in ./variable.test
Test that all core modules can be enabled, disabled and uninstalled.
variable_format_value in ./variable.module
Format printable value
variable_form_element_array in ./variable.form.inc
Build array form element
variable_form_element_default in ./variable.form.inc
Build default form element

... See full list

File

./variable.module, line 225
Variable API module

Code

function variable_get_value($variable, $options = array()) {
  $variable = _variable_variable($variable, $options);
  if (isset($variable['value'])) {
    return $variable['value'];
  }
  elseif (!empty($variable['value callback'])) {
    variable_include($variable);
    return variable_callback($variable['value callback'], $variable, _variable_options($options));
  }
  else {
    if (!empty($options['realm'])) {
      $value = $options['realm']
        ->variable_get($variable['name'], NULL);
    }
    else {
      $value = variable_get($variable['name'], NULL);
    }
    if (isset($value)) {
      return $value;
    }
    else {
      return isset($options['default']) ? $options['default'] : variable_get_default($variable, $options);
    }
  }
}