mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 01:53:49 +00:00
fix bug when the form "add role" fails
This commit is contained in:
@@ -246,10 +246,13 @@ class PermissionsGroupController extends Controller
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);
|
||||
$permissionsGroup = $em
|
||||
->getRepository('ChillMainBundle:PermissionsGroup')
|
||||
->find($id);
|
||||
|
||||
if (!$permissionsGroup) {
|
||||
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
|
||||
throw $this->createNotFoundException('Unable to find Permissions'
|
||||
. 'Group entity.');
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($permissionsGroup);
|
||||
@@ -269,9 +272,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) {
|
||||
@@ -418,10 +433,22 @@ 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,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'role_scopes_sorted' => $roleScopesSorted,
|
||||
'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
|
||||
'delete_role_scopes_form' => array_map( function($form) {
|
||||
|
||||
|
Reference in New Issue
Block a user