From 00f21f838bd3b7905f0f21153a76525fc5046a11 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 20 Oct 2016 02:11:13 +0000 Subject: [PATCH] DirectorObjectForm: simplify inhertance code --- .../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 8da99839..329127c4 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); } + } - foreach ($props as $k => $v) { - $this->setElementValue($k, $v); - if ($k !== 'object_name' && property_exists($inherited, $k)) { + protected function showInheritedProperties($object) + { + $inherited = $object->getInheritedProperties(); + $origins = $object->getOriginsProperties(); + + 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); } }