8.5.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.0.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.1.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.2.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.3.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.4.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)
8.6.x entity.api.php hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account)

Control entity operation access for a specific entity type.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check access to.

string $operation: The operation that is to be performed on $entity.

\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()

hook_entity_access()

Related topics

10 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.

content_moderation_entity_field_access in core/modules/content_moderation/content_moderation.module
Implements hook_entity_field_access().
entity_test_entity_create_access in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_entity_create_access().
entity_test_entity_field_access in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_entity_field_access().
entity_test_entity_test_access in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_ENTITY_TYPE_access() for 'entity_test'.
entity_test_entity_test_create_access in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_ENTITY_TYPE_create_access() for 'entity_test'.

... See full list

File

core/lib/Drupal/Core/Entity/entity.api.php, line 606
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();
}