class VariableRealmDefaultStore in Variable 7.2
Base class, keeps static list of variables.
Hierarchy
- class \VariableRealmDefaultStore implements VariableRealmStoreInterface
Expanded class hierarchy of VariableRealmDefaultStore
1 string reference to 'VariableRealmDefaultStore'
- VariableRealmDefaultController::createStore in variable_realm/
variable_realm.class.inc - Create Store for key.
File
- variable_realm/
variable_realm.class.inc, line 433 - Variable realm controller
View source
class VariableRealmDefaultStore implements VariableRealmStoreInterface {
public $realm;
public $key;
protected $variables;
/**
* Class constructor.
*/
public function __construct($realm, $key, $variables = NULL) {
$this->realm = $realm;
$this->key = $key;
$this->variables = $variables;
}
/**
* Initialize variables.
*/
public function variable_init() {
if (!isset($this->variables)) {
$this->variables = array();
}
}
/**
* Get single variable.
*
* @param $name
* Variable name
* @param $default
* Default value
*/
public function variable_get($name, $default = NULL) {
$this
->variable_init();
return isset($this->variables[$name]) ? $this->variables[$name] : $default;
}
/**
* Set single variable.
*
* @param $name
* Variable name
* @param $value
* Variable value
*/
public function variable_set($name, $value) {
$this
->variable_init();
$this->variables[$name] = $value;
}
/**
* Delete single variable.
*
* @param $name
* Variable name
*/
public function variable_del($name) {
$this
->variable_init();
unset($this->variables[$name]);
}
/**
* Implementation of VariableRealmStoreInterface::variable_add().
*/
public function variable_add($name, $value) {
$this
->variable_init();
$this->variables[$name] = $value;
}
/**
* Implementation of VariableRealmStoreInterface::variable_exists().
*/
public function variable_exists($name) {
$this
->variable_init();
return isset($this->variables[$name]);
}
/**
* List all current variable values.
*/
public function variable_list() {
$this
->variable_init();
return $this->variables;
}
}