Esempio n. 1
0
 /**
  * Display a confirmation form to remove the backend identified by the 'backend' parameter
  */
 public function removeuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $backendName = $this->params->getRequired('backend');
     $backendForm = new UserBackendConfigForm();
     $backendForm->setIniConfig(Config::app('authentication'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('config/userbackend');
     $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('User backend "%s" successfully removed'), $backendName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->renderForm($form, $this->translate('Remove User Backend'));
 }
Esempio n. 2
0
 /**
  * Action for removing a user backend
  */
 public function removeuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) {
         $configForm = new UserBackendConfigForm();
         $configForm->setIniConfig(Config::app('authentication'));
         $authBackend = $form->getRequest()->getQuery('backend');
         try {
             $configForm->remove($authBackend);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($configForm->save()) {
             Notification::success(sprintf(t('User backend "%s" has been successfully removed'), $authBackend));
         } else {
             return false;
         }
     }));
     $form->setTitle($this->translate('Remove User Backend'));
     $form->setRedirectUrl('config/userbackend');
     $form->setAction(Url::fromRequest());
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('userbackend/remove');
 }