class UserProtectRoleAccessCheck in User protect 8
Class UserProtectRoleAccessCheck.
@package Drupal\userprotect\Access
Hierarchy
- class \Drupal\userprotect\Access\UserProtectRoleAccessCheck implements AccessInterface
Expanded class hierarchy of UserProtectRoleAccessCheck
1 string reference to 'UserProtectRoleAccessCheck'
1 service uses UserProtectRoleAccessCheck
File
- src/
Access/ UserProtectRoleAccessCheck.php, line 15
Namespace
Drupal\userprotect\AccessView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UserProtectRoleAccessCheck:: |
public | function | Custom access check for the /user/%/roles. |