protected function ServerListBuilder::sortByStatusThenAlphabetically in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x src/ServerListBuilder.php \Drupal\oauth2_server\ServerListBuilder::sortByStatusThenAlphabetically()
Sorts an array of entities by status and then alphabetically.
Will preserve the key/value association of the array.
Parameters
\Drupal\Core\Config\Entity\ConfigEntityInterface[] $entities: An array of config entities.
1 call to ServerListBuilder::sortByStatusThenAlphabetically()
- ServerListBuilder::render in src/
ServerListBuilder.php - Builds the entity listing as renderable array for table.html.twig.
File
- src/
ServerListBuilder.php, line 131
Class
- ServerListBuilder
- Builds a listing of oauth2 server entities.
Namespace
Drupal\oauth2_serverCode
protected function sortByStatusThenAlphabetically(array &$entities) {
uasort($entities, function (ConfigEntityInterface $a, ConfigEntityInterface $b) {
if ($a
->status() == $b
->status()) {
return strnatcasecmp($a
->label(), $b
->label());
}
else {
return $a
->status() ? -1 : 1;
}
});
}