diff options
author | Simon | 2011-03-05 17:41:24 +0100 |
---|---|---|
committer | Simon | 2011-03-05 17:41:24 +0100 |
commit | 3a57892f9145bfadac4cf3bf4392020f99e0d541 (patch) | |
tree | 9e22a2749ae1713f4cc10395555d5757f6e52a36 /application/models/BootMenuEntries.php | |
parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
download | pbs2-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/BootMenuEntries.php')
-rw-r--r-- | application/models/BootMenuEntries.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/application/models/BootMenuEntries.php b/application/models/BootMenuEntries.php index 0b88402..9b6985c 100644 --- a/application/models/BootMenuEntries.php +++ b/application/models/BootMenuEntries.php @@ -89,6 +89,40 @@ class Application_Model_BootMenuEntries $this->_order = $_order; 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; + } } |