protected function PermissionHandler::sortPermissions in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/src/PermissionHandler.php \Drupal\user\PermissionHandler::sortPermissions()
- 10 core/modules/user/src/PermissionHandler.php \Drupal\user\PermissionHandler::sortPermissions()
Sorts the given permissions by provider name and title.
Parameters
array $all_permissions: The permissions to be sorted.
Return value
array[] Each return permission is an array with the following keys:
- title: The title of the permission.
- description: The description of the permission, defaults to NULL.
- provider: The provider of the permission.
1 call to PermissionHandler::sortPermissions()
- PermissionHandler::getPermissions in core/
modules/ user/ src/ PermissionHandler.php - Gets all available permissions.
File
- core/
modules/ user/ src/ PermissionHandler.php, line 201
Class
- PermissionHandler
- Provides the available permissions based on yml files.
Namespace
Drupal\userCode
protected function sortPermissions(array $all_permissions = []) {
// Get a list of all the modules providing permissions and sort by
// display name.
$modules = $this
->getModuleNames();
uasort($all_permissions, function (array $permission_a, array $permission_b) use ($modules) {
if ($modules[$permission_a['provider']] == $modules[$permission_b['provider']]) {
return $permission_a['title'] <=> $permission_b['title'];
}
else {
return $modules[$permission_a['provider']] <=> $modules[$permission_b['provider']];
}
});
return $all_permissions;
}