function entity_test_entity_create_access

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_create_access()
  2. 8.9.x core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_create_access()
  3. 10 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_create_access()

Implements hook_entity_create_access().

1 string reference to 'entity_test_entity_create_access'
EntityAccessControlHandlerTest::testHooks in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Tests hook invocations.

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 785

Code

function entity_test_entity_create_access(AccountInterface $account, $context, $entity_bundle) {
    \Drupal::state()->set('entity_test_entity_create_access', TRUE);
    \Drupal::state()->set('entity_test_entity_create_access_context', $context);
    if ($entity_bundle === 'forbidden_access_bundle') {
        // We need to cover a case in which a bundle is specifically forbidden
        // from creation (as opposed to neutral access).
        return AccessResult::forbidden();
    }
    // No opinion.
    return AccessResult::neutral();
}

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