summaryrefslogtreecommitdiffstats
path: root/application/models/Session.php
diff options
context:
space:
mode:
authorSimon2011-03-05 17:41:24 +0100
committerSimon2011-03-05 17:41:24 +0100
commit3a57892f9145bfadac4cf3bf4392020f99e0d541 (patch)
tree9e22a2749ae1713f4cc10395555d5757f6e52a36 /application/models/Session.php
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-3a57892f9145bfadac4cf3bf4392020f99e0d541.tar.gz
pbs2-3a57892f9145bfadac4cf3bf4392020f99e0d541.tar.xz
pbs2-3a57892f9145bfadac4cf3bf4392020f99e0d541.zip
filter-oberffäche fertig, nun zur auswahl des bootmenus && funktion toArray bei jedem Mapper hinzugefügt, um populate bei Formularen nutzen zu können
Diffstat (limited to 'application/models/Session.php')
-rw-r--r--application/models/Session.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/application/models/Session.php b/application/models/Session.php
index 73b6b4d..b042c17 100644
--- a/application/models/Session.php
+++ b/application/models/Session.php
@@ -101,5 +101,39 @@ class Application_Model_Session
$this->_ip6 = $_ip6;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}