public function render() { $template = $this->getTemplate(); $template->setFile(__DIR__ . '/roleDefinition.latte'); $resultSet = $this->userFacade->fetchAccessDefinitions(new AccessDefinitionQuery()); $template->accessDefinitions = $this->sortAccessDefinitions($resultSet->toArray()); $permissionsResultSet = $this->userFacade->fetchPermissions((new PermissionQuery())->byRole($this->role->getId())); $template->permissions = $this->sortRolePermissions($permissionsResultSet->toArray()); $template->role = $this->role->getName(); $template->render(); }
public function removeRole(SubmitButton $button) { if (!$this->authorizator->isAllowed($this->user, 'user_role', 'remove')) { $this->flashMessage('authorization.noPermission', FlashMessage::WARNING); $this->redirect('this'); } try { $this->userFacade->removeRole($this->role); $this->onSuccessRoleRemoval($this->role); } catch (ForeignKeyConstraintViolationException $e) { $this->flashMessage('users.roleRemoval.messages.roleInUse', FlashMessage::WARNING, ['roleName' => $this->role->getName()]); $this->redirect('this'); } }
public function onSuccessRolePermissionsEditing(Role $role) { $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has EDITED</b> permissions of Role [%s#%s]', $this->user->getId(), $this->user->getUsername(), $role->getId(), $role->getName()), 'user_role_editing', $this->user->getId()); }
/** * @return string */ public function getRoleName() { return $this->role->getName(); }
public function onSuccessRoleRemoval(Role $role) { $this->flashMessage('users.roleRemoval.messages.success', FlashMessage::SUCCESS, ['roleName' => $role->getName()]); $this->redirect('Users:roles'); }