PermissionHandler::sortPermissions

protected PermissionHandler::sortPermissions(array $all_permissions = array())

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.

File

core/modules/user/src/PermissionHandler.php, line 201

Class

PermissionHandler
Provides the available permissions based on yml files.

Namespace

Drupal\user

Code

protected function sortPermissions(array $all_permissions = array()) {
  // 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;
}
doc_Drupal
2016-10-29 09:33:40
Comments
Leave a Comment

Please login to continue.