Example #1
0
 /**
  * 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;
 }
 /**
  * Display a confirmation form to remove a resource
  */
 public function removeresourceAction()
 {
     $this->assertPermission('config/application/resources');
     $this->getTabs()->add('resources/remove', array('label' => $this->translate('Remove Resource'), 'url' => Url::fromRequest()))->activate('resources/remove');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) {
         $configForm = new ResourceConfigForm();
         $configForm->setIniConfig(Config::app('resources'));
         $resource = $form->getRequest()->getQuery('resource');
         try {
             $configForm->remove($resource);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($configForm->save()) {
             Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource));
         } else {
             return false;
         }
     }));
     $form->setRedirectUrl('config/resource');
     $form->handleRequest();
     // Check if selected resource is currently used for authentication
     $resource = $this->getRequest()->getQuery('resource');
     $authConfig = Config::app('authentication');
     foreach ($authConfig as $backendName => $config) {
         if ($config->get('resource') === $resource) {
             $form->addDescription(sprintf($this->translate('The resource "%s" is currently utilized for authentication by user backend "%s". ' . 'Removing the resource can result in noone being able to log in any longer.'), $resource, $backendName));
         }
     }
     $this->view->form = $form;
     $this->render('resource/remove');
 }