show unique inherited roles

This commit is contained in:
Yonel Ceruto 2017-06-05 13:09:00 -04:00
parent 20485d1f9b
commit 7061bfbf3a
2 changed files with 7 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class SecurityDataCollector extends DataCollector
'token_class' => get_class($token),
'user' => $token->getUsername(),
'roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $assignedRoles),
'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles),
'inherited_roles' => array_unique(array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles)),
'supports_role_hierarchy' => null !== $this->roleHierarchy,
);
}

View File

@ -111,6 +111,11 @@ class SecurityDataCollectorTest extends TestCase
array('ROLE_ADMIN'),
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
),
array(
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
),
);
}
@ -118,6 +123,7 @@ class SecurityDataCollectorTest extends TestCase
{
return new RoleHierarchy(array(
'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
'ROLE_OPERATOR' => array('ROLE_USER'),
));
}