user_access_test.module in Zircon Profile 8
Same filename and directory in other branches
Dummy module implementing hook_user_access() to test if entity access is respected.
File
core/modules/user/tests/modules/user_access_test/user_access_test.moduleView source
<?php
/**
* @file
* Dummy module implementing hook_user_access() to test if entity access is respected.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\user\Entity\User;
/**
* Implements hook_ENTITY_TYPE_access() for entity type "user".
*/
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();
}
Functions
Name | Description |
---|---|
user_access_test_user_access | Implements hook_ENTITY_TYPE_access() for entity type "user". |