You are here

function user_access_test_user_access in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/tests/modules/user_access_test/user_access_test.module \user_access_test_user_access()

Implements hook_ENTITY_TYPE_access() for entity type "user".

File

core/modules/user/tests/modules/user_access_test/user_access_test.module, line 14
Dummy module implementing hook_user_access() to test if entity access is respected.

Code

function user_access_test_user_access(User $entity, $operation, $account) {
  if ($entity
    ->getUsername() == "no_edit" && $operation == "update") {

    // Deny edit access.
    return AccessResult::forbidden();
  }
  if ($entity
    ->getUsername() == "no_delete" && $operation == "delete") {

    // Deny delete access.
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
}