function PermissionHandler::sortPermissions
Sorts the given permissions by provider name and title.
Parameters
array $all_permissions: The permissions to be sorted.
Return value
array[] An array with the same structure as PermissionHandlerInterface::getPermissions().
See also
\Drupal\user\PermissionHandlerInterface::getPermissions()
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 218  
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.