You are here

class UserProtectRoleAccessCheck in User protect 8

Class UserProtectRoleAccessCheck.

@package Drupal\userprotect\Access

Hierarchy

Expanded class hierarchy of UserProtectRoleAccessCheck

1 string reference to 'UserProtectRoleAccessCheck'
userprotect.services.yml in ./userprotect.services.yml
userprotect.services.yml
1 service uses UserProtectRoleAccessCheck
access_check.user_protect.role_access in ./userprotect.services.yml
Drupal\userprotect\Access\UserProtectRoleAccessCheck

File

src/Access/UserProtectRoleAccessCheck.php, line 15

Namespace

Drupal\userprotect\Access
View source
class UserProtectRoleAccessCheck implements AccessInterface {

  /**
   * Custom access check for the /user/%/roles.
   *
   * This check will only occur when role_delegation is enabled.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   * @param \Drupal\user\UserInterface $user
   *   The user we are editing.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account, UserInterface $user) {
    $access_result = $user
      ->access('user_roles', $account) ? AccessResult::allowed() : AccessResult::forbidden();
    return $access_result
      ->cachePerUser()
      ->addCacheableDependency($user);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserProtectRoleAccessCheck::access public function Custom access check for the /user/%/roles.