function hook_ENTITY_TYPE_access in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_ENTITY_TYPE_access()
Control entity operation access for a specific entity type.
Note that this hook is not called for listings (e.g., from entity queries and Views). For nodes, see Node access rights for a full explanation. For other entity types, see hook_query_TAG_alter().
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to check access to.
string $operation: The operation that is to be performed on $entity. Usually one of:
- "view"
- "update"
- "delete"
\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.
See also
\Drupal\Core\Entity\EntityAccessControlHandler
hook_ENTITY_TYPE_create_access()
Related topics
52 functions implement hook_ENTITY_TYPE_access()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_breadcrumb_test_node_access in core/
modules/ book/ tests/ modules/ book_breadcrumb_test/ book_breadcrumb_test.module - Implements hook_node_access().
- config_test_rest_config_test_access in core/
modules/ rest/ tests/ modules/ config_test_rest/ config_test_rest.module - Implements hook_ENTITY_TYPE_access().
- content_moderation_entity_access in core/
modules/ content_moderation/ content_moderation.module - Implements hook_entity_access().
- content_moderation_entity_field_access in core/
modules/ content_moderation/ content_moderation.module - Implements hook_entity_field_access().
- content_moderation_workspace_access in core/
modules/ content_moderation/ content_moderation.module - Implements hook_ENTITY_TYPE_access() for the 'workspace' entity type.
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 712 - Hooks and documentation related to entities.
Code
function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
// No opinion.
return AccessResult::neutral();
}