Advertisement
Guest User

Untitled

a guest
May 29th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. class DomainVariable {
  2. private $domain;
  3.  
  4. function __construct($domain = null) {
  5. if($domain == null) {
  6. $this->domain = DomainVariable::get_domain();
  7. } else {
  8. $this->domain $domain;
  9. }
  10. }
  11.  
  12. function get($name) {
  13. $all = variable_get($name, null);
  14. if($all != null) {
  15. return $all[$this->domain];
  16. }
  17. return null;
  18. }
  19.  
  20. function set($name, $value) {
  21. $existing = variable_get($name, null);
  22. if($existing != null) {
  23. $existing[$this->domain] = $value;
  24. variable_set($name, $existing);
  25. } else {
  26. variable_set($name, array($this->domain => $value));
  27. }
  28. }
  29.  
  30. static function get_domain() {
  31. return domain_get_domain();
  32. }
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement