DirectorObjectForm: simplify inhertance code

This commit is contained in:
Thomas Gelf 2016-10-20 02:11:13 +00:00
parent 09e9b7aa10
commit 00f21f838b

View File

@ -236,23 +236,20 @@ abstract class DirectorObjectForm extends QuickForm
$this->setDefaults($props); $this->setDefaults($props);
if (! $object instanceof IcingaObject) { if ($resolve) {
return $this; $this->showInheritedProperties($object);
}
} }
if ($resolve) { protected function showInheritedProperties($object)
{
$inherited = $object->getInheritedProperties(); $inherited = $object->getInheritedProperties();
$origins = $object->getOriginsProperties(); $origins = $object->getOriginsProperties();
} else {
$inherited = (object) array();
$origins = (object) array();
}
foreach ($props as $k => $v) { foreach ($inherited as $k => $v) {
$this->setElementValue($k, $v); if ($v !== null && $k !== 'object_name') {
if ($k !== 'object_name' && property_exists($inherited, $k)) {
$el = $this->getElement($k); $el = $this->getElement($k);
if ($el && $resolve) { if ($el) {
$this->setInheritedValue($el, $inherited->$k, $origins->$k); $this->setInheritedValue($el, $inherited->$k, $origins->$k);
} }
} }