function UserAccessTestHooks::entityCreateAccess

Implements hook_entity_create_access().

File

core/modules/user/tests/modules/user_access_test/src/Hook/UserAccessTestHooks.php, line 42

Class

UserAccessTestHooks
Hook implementations for user_access_test.

Namespace

Drupal\user_access_test\Hook

Code

public function entityCreateAccess(AccountInterface $account, array $context, $entity_bundle) {
    if ($context['entity_type_id'] != 'user') {
        return AccessResult::neutral();
    }
    // Account with role sub-admin can create users.
    return AccessResult::allowedIfHasPermission($account, 'sub-admin');
}

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