mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
DirectorObjectForm: separate deletion logic
This commit is contained in:
parent
621e561732
commit
d943195732
@ -495,28 +495,7 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
$object = $this->object();
|
$object = $this->object();
|
||||||
|
|
||||||
if ($this->shouldBeDeleted()) {
|
if ($this->shouldBeDeleted()) {
|
||||||
$key = $object->getKeyName();
|
$this->deleteObject($object);
|
||||||
if ($object instanceof IcingaObject) {
|
|
||||||
$msg = sprintf(
|
|
||||||
'%s "%s" has been removed',
|
|
||||||
$this->translate($this->getObjectName()),
|
|
||||||
$object->object_name
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$msg = sprintf(
|
|
||||||
'%s has been removed',
|
|
||||||
$this->translate($this->getObjectName())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($object->delete()) {
|
|
||||||
// fields? $this->setSuccessUrl($this->getSuccessUrl()->without($key));
|
|
||||||
if ($object instanceof IcingaObject) {
|
|
||||||
$this->setSuccessUrl('director/' . $object->getShortTableName() . 's');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: show object name and so
|
|
||||||
$this->redirectOnSuccess($msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
@ -542,6 +521,32 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
$this->handleProperties($object, $values);
|
$this->handleProperties($object, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function deleteObject($object)
|
||||||
|
{
|
||||||
|
$key = $object->getKeyName();
|
||||||
|
if ($object instanceof IcingaObject) {
|
||||||
|
$msg = sprintf(
|
||||||
|
'%s "%s" has been removed',
|
||||||
|
$this->translate($this->getObjectName()),
|
||||||
|
$object->object_name
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$msg = sprintf(
|
||||||
|
'%s has been removed',
|
||||||
|
$this->translate($this->getObjectName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->delete()) {
|
||||||
|
// fields? $this->setSuccessUrl($this->getSuccessUrl()->without($key));
|
||||||
|
if ($object instanceof IcingaObject) {
|
||||||
|
$this->setSuccessUrl('director/' . $object->getShortTableName() . 's');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: show object name and so
|
||||||
|
$this->redirectOnSuccess($msg);
|
||||||
|
}
|
||||||
|
|
||||||
protected function addDeleteButton($label = null)
|
protected function addDeleteButton($label = null)
|
||||||
{
|
{
|
||||||
if ($label === null) {
|
if ($label === null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user