variable_store.class.inc 1.1 KB

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