Skip to content

Commit

Permalink
role ID filter - backport of #5770 for 11.x (#5772)
Browse files Browse the repository at this point in the history
* add role name parameter - fixes #5768 for 11.x

* phpcs

* backport #5770
  • Loading branch information
malcomio committed Oct 4, 2023
1 parent fd8d4e4 commit 42794ce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Drupal/Commands/core/RoleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public function roleRemovePerm($machine_name, $permissions): void
/**
* Display a list of all roles defined on the system.
*
* If a role name is provided as an argument, then all of the permissions of
* that role will be listed. If a permission name is provided as an option,
* then all of the roles that have been granted that permission will be listed.
*
* @command role:list
* @usage drush role:list authenticated
* Display permissions for the 'authenticated' role.
* @usage drush role:list --filter='administer nodes'
* Display a list of roles that have the administer nodes permission assigned.
* Display a list of roles that have the 'administer nodes' permission assigned.
* @usage drush role:list --filter='rid=anonymous'
* Display only the 'anonymous' role.
* @aliases rls,role-list
* @field-labels
* rid: ID
Expand All @@ -118,11 +118,13 @@ public function roleRemovePerm($machine_name, $permissions): void
public function roleList($options = ['format' => 'yaml']): RowsOfFields
{
$rows = [];

$roles = Role::loadMultiple();
foreach ($roles as $role) {
$rows[$role->id()] = [
'label' => $role->label(),
'perms' => $role->getPermissions(),
'rid' => $role->id(),
'label' => $role->label(),
'perms' => $role->getPermissions(),
];
}
$result = new RowsOfFields($rows);
Expand Down

0 comments on commit 42794ce

Please sign in to comment.