mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaServiceForm: combine duplicate code
This commit is contained in:
parent
c296b716de
commit
21a67e355f
@ -497,13 +497,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||
->addExtraInfoElements()
|
||||
->setButtons();
|
||||
|
||||
if ($this->hasBeenSent()) {
|
||||
$name = $this->getSentOrObjectValue('object_name');
|
||||
if (!strlen($name)) {
|
||||
$this->setElementValue('object_name', end($imports));
|
||||
$this->object->object_name = end($imports);
|
||||
}
|
||||
}
|
||||
$this->setDefaultNameFromTemplate($imports);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -547,13 +541,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||
->addExtraInfoElements();
|
||||
}
|
||||
|
||||
if ($this->hasBeenSent()) {
|
||||
$name = $this->getSentOrObjectValue('object_name');
|
||||
if (!strlen($name)) {
|
||||
$this->setElementValue('object_name', end($imports));
|
||||
$this->object->object_name = end($imports);
|
||||
}
|
||||
}
|
||||
$this->setDefaultNameFromTemplate($imports);
|
||||
}
|
||||
|
||||
public function setServiceSet(IcingaServiceSet $set)
|
||||
@ -759,4 +747,18 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||
|
||||
return parent::onSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $imports
|
||||
*/
|
||||
protected function setDefaultNameFromTemplate($imports)
|
||||
{
|
||||
if ($this->hasBeenSent()) {
|
||||
$name = $this->getSentOrObjectValue('object_name');
|
||||
if (!strlen($name)) {
|
||||
$this->setElementValue('object_name', end($imports));
|
||||
$this->object->set('object_name', end($imports));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user