[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-set-12891: DirectorObjectForm: simplify inhertance code

git at icinga.org git at icinga.org
Thu Oct 20 09:26:58 CEST 2016


Module: icingaweb2-module-director
Branch: feature/service-set-12891
Commit: 5419f828e4e022221b49c0dec3022f9ee5a99721
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=5419f828e4e022221b49c0dec3022f9ee5a99721

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 20 02:11:13 2016 +0000

DirectorObjectForm: simplify inhertance code

---

 library/Director/Web/Form/DirectorObjectForm.php |   23 ++++++++++------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index 613e6fc..7cd5c59 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -236,23 +236,20 @@ abstract class DirectorObjectForm extends QuickForm
 
         $this->setDefaults($props);
 
-        if (! $object instanceof IcingaObject) {
-            return $this;
-        }
-
         if ($resolve) {
-            $inherited = $object->getInheritedProperties();
-            $origins   = $object->getOriginsProperties();
-        } else {
-            $inherited = (object) array();
-            $origins   = (object) array();
+            $this->showInheritedProperties($object);
         }
+    }
+
+    protected function showInheritedProperties($object)
+    {
+        $inherited = $object->getInheritedProperties();
+        $origins   = $object->getOriginsProperties();
 
-        foreach ($props as $k => $v) {
-            $this->setElementValue($k, $v);
-            if ($k !== 'object_name' && property_exists($inherited, $k)) {
+        foreach ($inherited as $k => $v) {
+            if ($v !== null && $k !== 'object_name') {
                 $el = $this->getElement($k);
-                if ($el && $resolve) {
+                if ($el) {
                     $this->setInheritedValue($el, $inherited->$k, $origins->$k);
                 }
             }



More information about the icinga-checkins mailing list