mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 00:34:05 +02:00
IcingaMultiEditForm: use IcingaObjectFormHook
This commit is contained in:
parent
93a882f8c5
commit
da909907fd
@ -3,6 +3,7 @@
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Data\Db\DbObject;
|
||||
use Icinga\Module\Director\Hook\IcingaObjectFormHook;
|
||||
use Icinga\Module\Director\Web\Form\IcingaObjectFieldLoader;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
@ -28,6 +29,11 @@ class IcingaMultiEditForm extends DirectorObjectForm
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isMultiObjectForm()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function pickElementsFrom(QuickForm $form, $properties)
|
||||
{
|
||||
$this->relatedForm = $form;
|
||||
@ -97,6 +103,7 @@ class IcingaMultiEditForm extends DirectorObjectForm
|
||||
*/
|
||||
protected function onRequest()
|
||||
{
|
||||
IcingaObjectFormHook::callOnSetup($this);
|
||||
if ($this->hasBeenSent()) {
|
||||
$this->handlePost();
|
||||
}
|
||||
@ -104,6 +111,7 @@ class IcingaMultiEditForm extends DirectorObjectForm
|
||||
|
||||
protected function handlePost()
|
||||
{
|
||||
$this->callOnRequestCallables();
|
||||
if ($this->shouldBeDeleted()) {
|
||||
$this->deleteObjects();
|
||||
}
|
||||
@ -278,9 +286,14 @@ class IcingaMultiEditForm extends DirectorObjectForm
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
protected function getObjects($names)
|
||||
public function getObjects($names = null)
|
||||
{
|
||||
if ($names === null) {
|
||||
return $this->objects;
|
||||
}
|
||||
|
||||
$res = array();
|
||||
|
||||
foreach ($names as $name) {
|
||||
$res[$name] = $this->objects[$name];
|
||||
}
|
||||
|
@ -688,6 +688,24 @@ abstract class DirectorObjectForm extends DirectorForm
|
||||
return $this->object !== null;
|
||||
}
|
||||
|
||||
public function isIcingaObject()
|
||||
{
|
||||
if ($this->object !== null) {
|
||||
return $this->object instanceof IcingaObject;
|
||||
}
|
||||
|
||||
/** @var DbObject $class */
|
||||
$class = $this->getObjectClassname();
|
||||
$instance = $class::create();
|
||||
|
||||
return $instance instanceof IcingaObject;
|
||||
}
|
||||
|
||||
public function isMultiObjectForm()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setObject(DbObject $object)
|
||||
{
|
||||
$this->object = $object;
|
||||
|
Loading…
x
Reference in New Issue
Block a user