function EntityTestHooks::entityCreateAccess
Implements hook_entity_create_access().
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php, line 653
Class
- EntityTestHooks
- Hook implementations for entity_test.
Namespace
Drupal\entity_test\HookCode
public function entityCreateAccess(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.