You are here

protected function AccessManager::roleAccess in Administer Users by Role 8.3

Checks access for a given role.

2 calls to AccessManager::roleAccess()
AccessManager::access in src/Services/AccessManager.php
Check access for the specified roles.
AccessManager::listRoles in src/Services/AccessManager.php
List all accessible roles for the specified operation.

File

src/Services/AccessManager.php, line 182

Class

AccessManager
Access Manager.

Namespace

Drupal\administerusersbyrole\Services

Code

protected function roleAccess($operation, AccountInterface $account, $rid) {
  if ($rid == AccountInterface::AUTHENTICATED_ROLE) {
    return self::SAFE;
  }
  $setting = $this->config
    ->get("roles.{$rid}") ?: self::UNSAFE;
  switch ($setting) {
    case self::SAFE:
      return TRUE;
    case self::UNSAFE:
      return FALSE;
    case self::PERM:
      return $this
        ->hasPerm($operation, $account, $rid);
  }
}