icingaweb2-module-director/application/forms/IcingaDeleteObjectForm.php

43 lines
927 B
PHP
Raw Normal View History

2015-07-28 15:15:08 +02:00
<?php
// TODO: Check whether this can be removed
2015-07-28 15:15:08 +02:00
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Web\Form\QuickForm;
class IcingaDeleteObjectForm extends QuickForm
{
2016-11-01 18:28:36 +01:00
/** @var IcingaObject */
2015-07-28 15:15:08 +02:00
protected $object;
public function setup()
{
$this->submitLabel = sprintf(
$this->translate('YES, please delete "%s"'),
2016-11-01 18:28:36 +01:00
$this->object->getObjectName()
2015-07-28 15:15:08 +02:00
);
}
public function onSuccess()
{
$object = $this->object;
$msg = sprintf(
'The %s "%s" has been deleted',
2015-07-28 15:15:08 +02:00
$object->getShortTableName(),
2016-11-01 18:28:36 +01:00
$object->getObjectName()
2015-07-28 15:15:08 +02:00
);
if ($object->delete()) {
$this->redirectOnSuccess($msg);
}
}
public function setObject(IcingaObject $object)
{
$this->object = $object;
return $this;
}
}