Skip to content

Commit

Permalink
add role name parameter - fixes #5768 for 12.x (#5770)
Browse files Browse the repository at this point in the history
* add role name parameter - fixes #5768 for 12.x

* phpcs

* Add rid to output and provide filetr examples.

* undo prior changes in PR

* No machine name

* Description

---------

Co-authored-by: Moshe Weitzman <weitzman@tejasa.com>
  • Loading branch information
malcomio and weitzman authored Sep 28, 2023
1 parent 17c9277 commit 78aa3b9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Commands/core/RoleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ 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.
* Display roles and their permissions.
*/
#[CLI\Command(name: self::LIST, aliases: ['rls', 'role-list'])]
#[CLI\Usage(name: "drush role:list --filter='administer nodes'", description: 'Display a list of roles that have the administer nodes permission assigned.')]
#[CLI\Usage(name: "drush role:list --filter='rid=anonymous'", description: 'Display only the anonymous role.')]
#[CLI\FieldLabels(labels: ['rid' => 'ID', 'label' => 'Role Label', 'perms' => 'Permissions'])]
#[CLI\FilterDefaultField(field: 'perms')]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
Expand All @@ -118,8 +115,9 @@ public function roleList($options = ['format' => 'yaml']): RowsOfFields
$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 78aa3b9

Please sign in to comment.