Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityAccessControlHandler.php

function EntityAccessControlHandler::buildCreateAccessCid

Builds the create access result cache ID.

If there is no context other than langcode and entity type id, then the cache id can be simply the bundle. Otherwise, a custom implementation is needed to ensure cacheability, and the default implementation here returns null.

Parameters

array $context: The create access context.

string|null $entity_bundle: The entity bundle, if the entity type has bundles.

Return value

string|null The create access result cache ID, or null if uncacheable.

1 call to EntityAccessControlHandler::buildCreateAccessCid()
EntityAccessControlHandler::createAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to create an entity.

File

core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php, line 422

Class

EntityAccessControlHandler
Defines a default implementation for entity access control handler.

Namespace

Drupal\Core\Entity

Code

protected function buildCreateAccessCid(array $context, ?string $entity_bundle) : ?string {
    $extendedContext = array_filter($context, function ($key) {
        return !in_array($key, [
            'entity_type_id',
            'langcode',
        ]);
    }, ARRAY_FILTER_USE_KEY);
    if (empty($extendedContext)) {
        return $entity_bundle ? 'create:' . $entity_bundle : 'create';
    }
    return NULL;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal