Exemplo n.º 1
0
 /**
  * Remove a command transport
  */
 public function removetransportAction()
 {
     $transportName = $this->params->getRequired('transport');
     $transportForm = new TransportConfigForm();
     $transportForm->setIniConfig($this->Config('commandtransports'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('monitoring/config');
     $form->setTitle(sprintf($this->translate('Remove Command Transport %s'), $transportName));
     $form->info($this->translate('If you still have any environments or views referring to this transport, ' . 'you won\'t be able to send commands anymore after deletion.'), false);
     $form->setOnSuccess(function (ConfirmRemovalForm $form) use($transportName, $transportForm) {
         try {
             $transportForm->delete($transportName);
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($transportForm->save()) {
             Notification::success(sprintf(t('Command transport "%s" successfully removed'), $transportName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }