Beispiel #1
0
 /**
  * Create a new role
  *
  * @TODO(el): Rename to newAction()
  */
 public function addAction()
 {
     $this->assertPermission('config/authentication/roles/add');
     $role = new RoleForm(array('onSuccess' => function (RoleForm $role) {
         $name = $role->getElement('name')->getValue();
         $values = $role->getValues();
         try {
             $role->add($name, $values);
         } catch (AlreadyExistsException $e) {
             $role->addError($e->getMessage());
             return false;
         }
         if ($role->save()) {
             Notification::success(t('Role created'));
             return true;
         }
         return false;
     }));
     $role->setSubmitLabel($this->translate('Create Role'))->setIniConfig(Config::app('roles', true))->setRedirectUrl('role/list')->handleRequest();
     $this->renderForm($role, $this->translate('New Role'));
 }