1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Variable realm controller
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
class VariableStoreRealmStore extends VariableRealmDefaultStore {
|
8 |
|
|
/**
|
9 |
|
|
* Initialize realm.
|
10 |
|
|
*/
|
11 |
|
|
public function variable_init() {
|
12 |
|
|
if (!isset($this->variables)) {
|
13 |
|
|
$this->variables = &variable_store($this->realm, $this->key);
|
14 |
|
|
}
|
15 |
|
|
}
|
16 |
|
|
/**
|
17 |
|
|
* Set single variable.
|
18 |
|
|
*
|
19 |
|
|
* @param $name
|
20 |
|
|
* Variable name
|
21 |
|
|
* @param $value
|
22 |
|
|
* Variable value
|
23 |
|
|
*/
|
24 |
|
|
public function variable_set($name, $value) {
|
25 |
|
|
// Since $variables is a reference we just need to set the store value.
|
26 |
|
|
variable_store_set($this->realm, $this->key, $name, $value);
|
27 |
|
|
}
|
28 |
|
|
/**
|
29 |
|
|
* Delete single variable.
|
30 |
|
|
*
|
31 |
|
|
* @param $name
|
32 |
|
|
* Variable name
|
33 |
|
|
*/
|
34 |
|
|
public function variable_del($name) {
|
35 |
|
|
// Since $variables is a reference we just need to delete the store value.
|
36 |
|
|
variable_store_del($this->realm, $this->key, $name);
|
37 |
|
|
}
|
38 |
|
|
/**
|
39 |
|
|
* Implements 'magic' _sleep method.
|
40 |
|
|
*
|
41 |
|
|
* If serialized, variables should not be saved, but rebuilt from store on wake up.
|
42 |
|
|
*/
|
43 |
|
|
public function __sleep(){
|
44 |
|
|
return array('realm', 'key');
|
45 |
|
|
}
|
46 |
|
|
} |