/** * Display a confirmation form to remove the backend identified by the 'backend' parameter */ public function removebackendAction() { $config = $this->Config('backends'); $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) use($config) { $backendName = $form->getRequest()->getQuery('backend'); $configForm = new BackendConfigForm(); $configForm->setIniConfig($config); try { $configForm->remove($backendName); } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); return; } if ($configForm->save()) { Notification::success(sprintf($this->translate('Backend "%s" successfully removed.'), $backendName)); } else { return false; } })); $form->setTitle($this->translate('Remove Existing Backend')); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); $this->view->form = $form; }
/** * Display a confirmation form to remove the backend identified by the 'backend' parameter */ public function removebackendAction() { $backendName = $this->params->getRequired('backend-name'); $backendForm = new BackendConfigForm(); $backendForm->setIniConfig($this->Config('backends')); $form = new ConfirmRemovalForm(); $form->setRedirectUrl('monitoring/config'); $form->setTitle(sprintf($this->translate('Remove Monitoring Backend %s'), $backendName)); $form->setOnSuccess(function (ConfirmRemovalForm $form) use($backendName, $backendForm) { try { $backendForm->delete($backendName); } catch (Exception $e) { $form->error($e->getMessage()); return false; } if ($backendForm->save()) { Notification::success(sprintf(t('Monitoring backend "%s" successfully removed'), $backendName)); return true; } return false; }); $form->handleRequest(); $this->view->form = $form; $this->render('form'); }