From da3d2a797f9184865ce5fd8baf9d2104687da081 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 5 Mar 2016 16:15:37 +0100 Subject: [PATCH] DirectorObjectForm: pass-through imports and groups --- .../Director/Web/Form/DirectorObjectForm.php | 59 ++++--------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index f0d14210..f3c29087 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -48,26 +48,6 @@ abstract class DirectorObjectForm extends QuickForm return $this->getSentOrObjectValue('object_type') === 'template'; } - protected function handleImports($object, & $values) - { - if (! $object->supportsImports()) { - return; - } - - if (array_key_exists('imports', $values)) { - $value = $values['imports']; - unset($values['imports']); - $object->clearImportedObjects(); - $object->imports()->set($value); - } - - $el = $this->getElement('imports'); - if ($el) { - $el->setMultiOptions($this->enumAllowedTemplates()); - $el->setValue($object->imports()->listImportNames()); - } - } - protected function handleRanges($object, & $values) { if (! $object->supportsRanges()) { @@ -166,25 +146,6 @@ abstract class DirectorObjectForm extends QuickForm return $this->displayGroups[$group]; } - protected function handleGroups($object, & $values) - { - if (! $object->supportsGroups()) { - return; - } - - if (array_key_exists('groups', $values)) { - $value = $values['groups']; - unset($values['groups']); - - // TODO: Drop this once we have arrays everwhere - if (is_string($value)) { - $value = preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); - } - - $object->groups()->set($value); - } - } - protected function handleProperties($object, & $values) { if ($this->hasBeenSent()) { @@ -197,18 +158,18 @@ abstract class DirectorObjectForm extends QuickForm } } - $props = $object->getProperties(); + if ($object instanceof IcingaObject) { + $props = (array) $object->toPlainObject(); + } else { + $props = $object->getProperties(); + unset($props['vars']); + } + $this->setDefaults($props); if (! $object instanceof IcingaObject) { - $this->setDefaults($props); return $this; } - if (! $object->supportsImports()) { - $this->setDefaults($props); - return; - } - $inherited = $object->getInheritedProperties(); $origins = $object->getOriginsProperties(); @@ -757,6 +718,12 @@ abstract class DirectorObjectForm extends QuickForm if ($object->hasProperty($name)) { if ($resolved) { $objectProperty = $object->getResolvedProperty($name); +/* +var_dump($name); +var_dump($objectProperty); +print_r($object); + +*/ } else { $objectProperty = $object->$name; }