function EntityAccess::entityCreateAccess

Same name in this branch
  1. 11.x core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::entityCreateAccess()
Same name in other branches
  1. 9 core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::entityCreateAccess()
  2. 8.9.x core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::entityCreateAccess()
  3. 10 core/modules/workspaces/src/EntityAccess.php \Drupal\workspaces\EntityAccess::entityCreateAccess()

Implements hook_entity_create_access().

File

core/modules/workspaces/src/Hook/EntityAccess.php, line 55

Class

EntityAccess
Defines a class for reacting to entity access control hooks.

Namespace

Drupal\workspaces\Hook

Code

public function entityCreateAccess(AccountInterface $account, array $context, $entity_bundle) : AccessResultInterface {
    // Workspaces themselves are handled by their own access handler and we
    // should not try to do any access checks for entity types that can not
    // belong to a workspace.
    $entity_type = $this->entityTypeManager
        ->getDefinition($context['entity_type_id']);
    if (!$this->workspaceInfo
        ->isEntityTypeSupported($entity_type) || !$this->workspaceManager
        ->hasActiveWorkspace()) {
        return AccessResult::neutral();
    }
    return $this->bypassAccessResult($account);
}

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