function hook_entity_create_access

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create_access()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create_access()
  3. 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create_access()

Control entity create access.

Parameters

\Drupal\Core\Session\AccountInterface $account: The account trying to access the entity.

array $context: An associative array of additional context values. By default it contains language and the entity type ID:

  • entity_type_id - the entity type ID.
  • langcode - the current language code.

string $entity_bundle: The entity bundle name.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

See also

\Drupal\Core\Entity\EntityAccessControlHandler

hook_entity_access()

hook_ENTITY_TYPE_create_access()

Related topics

3 functions implement hook_entity_create_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_test_entity_create_access in core/modules/system/tests/modules/entity_test/entity_test.module
Implements hook_entity_create_access().
user_access_test_entity_create_access in core/modules/user/tests/modules/user_access_test/user_access_test.module
Implements hook_entity_create_access().
workspaces_entity_create_access in core/modules/workspaces/workspaces.module
Implements hook_entity_create_access().
1 invocation of hook_entity_create_access()
EntityAccessControlHandler::createAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to create an entity.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 768

Code

function hook_entity_create_access(\Drupal\Core\Session\AccountInterface $account, array $context, $entity_bundle) {
    // No opinion.
    return AccessResult::neutral();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.