You are here

function variable_realm_switch in Variable 7.2

Same name and namespace in other branches
  1. 7 variable_realm/variable_realm.module \variable_realm_switch()

Switch current variable realms.

Parameters

$realm: Realm name. Example 'language'.

$key: Realm key. Example, for language will be a language code, 'en FALSE to unset the realm.

$rebuild: Whether we need to rebuild the configuration.

See also

variable_realm_weight()

4 calls to variable_realm_switch()
VariableStoreTestCase::testVariableStoreAPI in variable_store/variable_store.test
Test that all core modules can be enabled, disabled and uninstalled.
variable_example_page_realm in variable_example/variable_example.module
Variable example realm page.
variable_realm_init in variable_realm/variable_realm.module
Implements hook_init()
variable_realm_reset in variable_realm/variable_realm.module
Reset realms, deleting currently set ones

File

variable_realm/variable_realm.module, line 383
Variable API module - Realms

Code

function variable_realm_switch($realm, $key, $rebuild = TRUE) {

  // Check previous status, if not changed no need to rebuild.
  $current = variable_realm_status($realm);
  if (!isset($current) || $current !== $key) {
    variable_realm_status($realm, $key);
    _variable_realm_invoke_all('variable_realm_switch', $realm, $key);
    _variable_realm_hook('variableRealmSwitch', $realm, $key);
    if ($rebuild) {
      variable_realm_rebuild();
    }
  }
}