/** * Display a confirmation form to remove the instance identified by the 'instance' parameter */ public function removeinstanceAction() { $config = $this->Config('instances'); $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) use($config) { $instanceName = $form->getRequest()->getQuery('instance'); $configForm = new InstanceConfigForm(); $configForm->setIniConfig($config); try { $configForm->remove($instanceName); } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); return; } if ($configForm->save()) { Notification::success(sprintf($this->translate('Instance "%s" successfully removed.'), $instanceName)); } else { return false; } })); $form->setTitle($this->translate('Remove Existing Instance')); $form->addDescription($this->translate('If you have still any environments or views referring to this instance, ' . 'you won\'t be able to send commands anymore after deletion.')); $form->addElement('note', 'question', array('value' => $this->translate('Are you sure you want to remove this instance?'), 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'p'))))); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); $this->view->form = $form; }