You are here

function administerusersbyrole_user_role_access in Administer Users by Role 8.3

Same name and namespace in other branches
  1. 8.2 administerusersbyrole.module \administerusersbyrole_user_role_access()

Implements hook_ENTITY_TYPE_access() for entity type "user_role".

Parameters

\Drupal\user\RoleInterface $role: The role object to check access for.

string $operation: The operation that is to be performed on $role.

\Drupal\Core\Session\AccountInterface $account: The account trying to access the entity.

Return value

\Drupal\Core\Access\AccessResultInterface The access result. hook_entity_access() has detailed documentation.

File

./administerusersbyrole.module, line 34
Administer Users by Role main module file.

Code

function administerusersbyrole_user_role_access(RoleInterface $role, $operation, AccountInterface $account) {

  // Allow users without the permission "administer permissions" to view the
  // role names in the /admin/people view.
  if ($operation == 'view') {
    return AccessResult::allowedIfHasPermission($account, 'access users overview');
  }
  return AccessResult::neutral();
}