You are here

protected function TeamPermissionHandler::sortPermissions in Apigee Edge 8

Sorts the given team permissions by category and title.

Parameters

array $all_permissions: The team permissions to be sorted.

Return value

\Drupal\apigee_edge_teams\Structure\TeamPermission[] Sorted team permissions.

1 call to TeamPermissionHandler::sortPermissions()
TeamPermissionHandler::getPermissions in modules/apigee_edge_teams/src/TeamPermissionHandler.php
Gets all available team permissions.

File

modules/apigee_edge_teams/src/TeamPermissionHandler.php, line 265

Class

TeamPermissionHandler
Provides the available team permissions based on yml files.

Namespace

Drupal\apigee_edge_teams

Code

protected function sortPermissions(array $all_permissions = []) {
  uasort($all_permissions, function (TeamPermission $permission_a, TeamPermission $permission_b) {
    if ($permission_a
      ->getCategory() == $permission_b
      ->getCategory()) {
      return $permission_a
        ->getLabel() > $permission_b
        ->getLabel();
    }
    else {
      return $permission_a
        ->getCategory() > $permission_b
        ->getCategory();
    }
  });
  return $all_permissions;
}