DirectorObjectForm: get rid of object_type magic

This commit is contained in:
Thomas Gelf 2016-02-17 21:50:06 +01:00
parent 1d24efd103
commit 7b1c17799d
1 changed files with 11 additions and 13 deletions

View File

@ -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 {