mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
Make a hierarchy in roles
This is more understandable for users.
This commit is contained in:
@@ -108,6 +108,8 @@ class PermissionsGroupController extends Controller
|
||||
|
||||
$translatableStringHelper = $this->get('chill.main.helper.translatable_string');
|
||||
$roleScopes = $permissionsGroup->getRoleScopes()->toArray();
|
||||
|
||||
// sort $roleScopes by name
|
||||
usort($roleScopes,
|
||||
function(RoleScope $a, RoleScope $b) use ($translatableStringHelper) {
|
||||
if ($a->getScope() === NULL) {
|
||||
@@ -122,10 +124,21 @@ class PermissionsGroupController extends Controller
|
||||
$translatableStringHelper->localize($b->getScope()->getName())
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// sort role scope by title
|
||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||
$roleProvider = $this->get('chill.main.role_provider');
|
||||
$roleScopesSorted = array();
|
||||
foreach($roleScopes as $roleScope) {
|
||||
/* @var $roleScope RoleScope */
|
||||
$title = $roleProvider->getRoleTitle($roleScope->getRole());
|
||||
$roleScopesSorted[$title][] = $roleScope;
|
||||
}
|
||||
ksort($roleScopesSorted);
|
||||
|
||||
return $this->render('ChillMainBundle:PermissionsGroup:show.html.twig', array(
|
||||
'entity' => $permissionsGroup,
|
||||
'role_scopes' => $roleScopes,
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'expanded_roles' => $this->getExpandedRoles($roleScopes)
|
||||
));
|
||||
}
|
||||
@@ -171,6 +184,7 @@ class PermissionsGroupController extends Controller
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
}
|
||||
|
||||
// create all the forms
|
||||
$editForm = $this->createEditForm($permissionsGroup);
|
||||
|
||||
$deleteRoleScopesForm = array();
|
||||
@@ -180,9 +194,21 @@ class PermissionsGroupController extends Controller
|
||||
}
|
||||
|
||||
$addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);
|
||||
|
||||
// sort role scope by title
|
||||
/* @var $roleProvider \Chill\MainBundle\Security\RoleProvider */
|
||||
$roleProvider = $this->get('chill.main.role_provider');
|
||||
$roleScopesSorted = array();
|
||||
foreach($permissionsGroup->getRoleScopes()->toArray() as $roleScope) {
|
||||
/* @var $roleScope RoleScope */
|
||||
$title = $roleProvider->getRoleTitle($roleScope->getRole());
|
||||
$roleScopesSorted[$title][] = $roleScope;
|
||||
}
|
||||
ksort($roleScopesSorted);
|
||||
|
||||
return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
|
||||
'entity' => $permissionsGroup,
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||
'delete_role_scopes_form' => array_map( function($form) {
|
||||
|
Reference in New Issue
Block a user