function EntityTestAccessControlHandler::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.

Overrides EntityAccessControlHandler::buildCreateAccessCid

File

core/modules/system/tests/modules/entity_test/src/EntityTestAccessControlHandler.php, line 108

Class

EntityTestAccessControlHandler
Defines the access control handler for the test entity type.

Namespace

Drupal\entity_test

Code

protected function buildCreateAccessCid(array $context, ?string $entity_bundle) : string {
  $cid = parent::buildCreateAccessCid([], $entity_bundle);
  $cid .= isset($context['context_var1']) ? ":{$context['context_var1']}" : '';
  $cid .= isset($context['context_var2']) ? ":{$context['context_var2']}" : '';
  return $cid;
}

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