/** * Remove a role */ public function removeAction() { $this->assertPermission('config/authentication/roles/remove'); $name = $this->params->getRequired('role'); $role = new RoleForm(); try { $role->setIniConfig(Config::app('roles', true))->load($name); } catch (NotFoundError $e) { $this->httpNotFound($e->getMessage()); } $confirmation = new ConfirmRemovalForm(array('onSuccess' => function (ConfirmRemovalForm $confirmation) use($name, $role) { try { $role->remove($name); } catch (NotFoundError $e) { Notification::error($e->getMessage()); return false; } if ($role->save()) { Notification::success(t('Role removed')); return true; } return false; })); $confirmation->setSubmitLabel($this->translate('Remove Role'))->setRedirectUrl('role/list')->handleRequest(); $this->renderForm($confirmation, $this->translate('Remove Role')); }