Exemplo n.º 1
0
 /**
  * Action for editing user backends
  */
 public function edituserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $form = new UserBackendConfigForm();
     $form->setTitle($this->translate('Edit User Backend'));
     $form->setIniConfig(Config::app('authentication'));
     $form->setResourceConfig(ResourceFactory::getResourceConfigs());
     $form->setRedirectUrl('config/userbackend');
     $form->setAction(Url::fromRequest());
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('userbackend/modify');
 }
Exemplo n.º 2
0
 /**
  * Edit a user backend
  */
 public function edituserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $backendName = $this->params->getRequired('backend');
     $form = new UserBackendConfigForm();
     $form->setRedirectUrl('config/userbackend');
     $form->setTitle(sprintf($this->translate('Edit User Backend %s'), $backendName));
     $form->setIniConfig(Config::app('authentication'));
     $form->setOnSuccess(function (UserBackendConfigForm $form) use($backendName) {
         try {
             $form->edit($backendName, array_map(function ($v) {
                 return $v !== '' ? $v : null;
             }, $form->getValues()));
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($form->save()) {
             Notification::success(sprintf(t('User backend "%s" successfully updated'), $backendName));
             return true;
         }
         return false;
     });
     try {
         $form->load($backendName);
         $form->setResourceConfig(ResourceFactory::getResourceConfigs());
         $form->handleRequest();
     } catch (NotFoundError $_) {
         $this->httpNotFound(sprintf($this->translate('User backend "%s" not found'), $backendName));
     }
     $this->view->form = $form;
     $this->render('form');
 }