From 7b1c17799d8d3d7d4306776851fdb686bc8e47cd Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 17 Feb 2016 21:50:06 +0100 Subject: [PATCH] DirectorObjectForm: get rid of object_type magic --- .../Director/Web/Form/DirectorObjectForm.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index d485b5a6..1c28baf1 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -18,8 +18,6 @@ abstract class DirectorObjectForm extends QuickForm protected $deleteButtonName; - protected $objectType = 'object'; - protected $fieldsDisplayGroup; protected $displayGroups = array(); @@ -46,7 +44,7 @@ abstract class DirectorObjectForm extends QuickForm protected function isTemplate() { - return $this->objectType === 'template'; + return $this->getSentOrObjectValue('object_type') === 'template'; } protected function handleImports($object, & $values) @@ -381,12 +379,6 @@ abstract class DirectorObjectForm extends QuickForm } } - public function setObjectType($type) - { - $this->objectType = $type; - return $this; - } - protected function setButtons() { if ($this->object === null || ! $this->object->hasBeenLoadedFromDb()) { @@ -629,9 +621,6 @@ abstract class DirectorObjectForm extends QuickForm } if ($object instanceof IcingaObject) { - if (! $object->hasBeenLoadedFromDb() && $object->hasProperty('object_type')) { - $object->object_type = $this->objectType; - } $this->handleImports($object, $values); $this->handleProperties($object, $values); $this->handleCustomVars($object, $post); @@ -721,6 +710,10 @@ abstract class DirectorObjectForm extends QuickForm return $object->$name; } + if (null !== ($val = $this->getElement('object_type')->getValue())) { + return $val; + } + return $default; } else { @@ -732,6 +725,10 @@ abstract class DirectorObjectForm extends QuickForm return $val; } + if (null !== ($val = $this->getElement('object_type')->getValue())) { + return $val; + } + return $default; } } @@ -788,7 +785,8 @@ abstract class DirectorObjectForm extends QuickForm if ($this->object()->supportsImports()) { $templates = $this->enumAllowedTemplates(); - if (empty($templates)) { + // TODO: getObjectname is a confusing method name + if (empty($templates) && $this->getObjectname() !== 'Command') { $default = 'template'; $types = array('template' => $this->translate('Template')); } else {