public function AccessManager::listRoles in Administer Users by Role 8.3
List all accessible roles for the specified operation.
Parameters
string $operation: The operation that is to be performed.
\Drupal\Core\Session\AccountInterface $account: The account trying to access the entity.
Return value
array of role IDs.
Overrides AccessManagerInterface::listRoles
File
- src/
Services/ AccessManager.php, line 124
Class
- AccessManager
- Access Manager.
Namespace
Drupal\administerusersbyrole\ServicesCode
public function listRoles($operation, AccountInterface $account) {
if (!$this
->preAccess($operation, $account)) {
return [];
}
$roles = [
AccountInterface::AUTHENTICATED_ROLE,
];
foreach (array_keys($this
->managedRoles()) as $rid) {
if ($this
->roleAccess($operation, $account, $rid)) {
$roles[] = $rid;
}
}
return $roles;
}