From b675d37b6fabd85b69b5feb4cd0ead732eb3353d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 25 Jul 2017 10:16:15 +0200 Subject: [PATCH] CloneObject: use modern loading --- application/forms/IcingaCloneObjectForm.php | 9 +++++---- library/Director/Web/Controller/ObjectController.php | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/application/forms/IcingaCloneObjectForm.php b/application/forms/IcingaCloneObjectForm.php index 0a33e03b..19d9608a 100644 --- a/application/forms/IcingaCloneObjectForm.php +++ b/application/forms/IcingaCloneObjectForm.php @@ -3,19 +3,20 @@ namespace Icinga\Module\Director\Forms; use Icinga\Module\Director\Objects\IcingaObject; -use Icinga\Module\Director\Web\Form\QuickForm; +use Icinga\Module\Director\Web\Form\DirectorForm; -class IcingaCloneObjectForm extends QuickForm +class IcingaCloneObjectForm extends DirectorForm { /** @var IcingaObject */ protected $object; public function setup() { + $name = $this->object->getObjectName(); $this->addElement('text', 'new_object_name', array( 'label' => $this->translate('New name'), 'required' => true, - 'value' => $this->object->getObjectName(), + 'value' => $name, )); $this->addElement('select', 'clone_type', array( @@ -29,7 +30,7 @@ class IcingaCloneObjectForm extends QuickForm $this->submitLabel = sprintf( $this->translate('Clone "%s"'), - $this->object->getObjectName() + $name ); } diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php index ca5730ab..f8debd24 100644 --- a/library/Director/Web/Controller/ObjectController.php +++ b/library/Director/Web/Controller/ObjectController.php @@ -10,6 +10,7 @@ use Icinga\Module\Director\Deployment\DeploymentInfo; use Icinga\Module\Director\Exception\DuplicateKeyException; use Icinga\Module\Director\Exception\NestingError; use Icinga\Module\Director\Forms\DeploymentLinkForm; +use Icinga\Module\Director\Forms\IcingaCloneObjectForm; use Icinga\Module\Director\Forms\IcingaObjectFieldForm; use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaObjectGroup; @@ -234,14 +235,15 @@ abstract class ObjectController extends ActionController $this->assertPermission('director/' . $ltype); $this->tabs()->activate('modify'); $this->addTitle($this->translate('Clone Icinga %s'), ucfirst($type)); - $form = $this->loadForm('icingaCloneObject')->setObject($this->object); - $form->handleRequest(); + $form = IcingaCloneObjectForm::load() + ->setObject($this->object) + ->handleRequest(); $this->content()->add($form); $this->actions()->add(Link::create( $this->translate('back'), 'director/' . $ltype, - array('name' => $this->object->object_name), - array('class' => 'icon-left-big') + ['name' => $this->object->getObjectName()], + ['class' => 'icon-left-big'] )); }