You are here

function variable_delete in Variable 7.2

Same name and namespace in other branches
  1. 7 variable.module \variable_delete()

Delete variable (included children variables)

Related topics

2 calls to variable_delete()
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.
1 string reference to 'variable_delete'
variable_module_uninstall in ./variable.inc
Uninstall variables for module

File

./variable.module, line 290
Variable API module

Code

function variable_delete($variable, $options = array()) {
  $variable = _variable_variable($variable, $options);
  variable_include();

  // We need to build the variable, it may be multiple
  $variable = variable_build($variable, $options);
  if (!empty($variable['children'])) {
    $callback = !empty($options['realm']) ? array(
      $options['realm'],
      'variable_del',
    ) : 'variable_del';
    array_map($callback, array_keys($variable['children']));
  }
  elseif (!empty($options['realm'])) {
    $options['realm']
      ->variable_del($variable['name']);
  }
  else {
    variable_del($variable['name']);
  }

  // Invoke the hook only once even if its multiple
  module_invoke_all('variable_delete', $variable, $options);
}