diff options
author | Simon | 2011-01-27 16:25:34 +0100 |
---|---|---|
committer | Simon | 2011-01-27 16:25:34 +0100 |
commit | 56d52ed8074385e4ad681db5616c2979ecf674ae (patch) | |
tree | 2b968ae2300e2cfa077bd466d9be1173eee28ffb /application/models/Session.php | |
parent | Models hinzugefügt (diff) | |
download | pbs2-56d52ed8074385e4ad681db5616c2979ecf674ae.tar.gz pbs2-56d52ed8074385e4ad681db5616c2979ecf674ae.tar.xz pbs2-56d52ed8074385e4ad681db5616c2979ecf674ae.zip |
erster änderungen an den Models, setter und getter fehlern noch
Diffstat (limited to 'application/models/Session.php')
-rw-r--r-- | application/models/Session.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/application/models/Session.php b/application/models/Session.php index 76351d0..8fa9748 100644 --- a/application/models/Session.php +++ b/application/models/Session.php @@ -2,7 +2,42 @@ class Application_Model_Session { + public function __construct(array $options = null) + { + if (is_array($options)) { + $this->setOptions($options); + } + } + public function __set($name, $value) + { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid guestbook property'); + } + $this->$method($value); + } + + public function __get($name) + { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid guestbook property'); + } + return $this->$method(); + } + + public function setOptions(array $options) + { + $methods = get_class_methods($this); + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (in_array($method, $methods)) { + $this->$method($value); + } + } + return $this; + } } |