// having them, use the 'entity type:ID' pattern as the cache $cid.
$cid =
$entity->
uuid() ?:
$entity->
getEntityTypeId() . ':' .
$entity->
id();
// If the entity is revisionable, then append the revision ID to allow
// individual revisions to have specific access control and be cached
// separately.
if ($entity instanceof RevisionableInterface
) { /** @var \Drupal\Core\Entity\RevisionableInterface $entity */
$cid .= ':' .
$entity->
getRevisionId();
} if (($return =
$this->
getCache($cid,
$operation,
$langcode,
$account)) !== NULL
) { // Cache hit, no work necessary.
return $return_as_object ?
$return :
$return->
isAllowed();
} // Invoke hook_entity_access() and hook_ENTITY_TYPE_access(). Hook results
// take precedence over overridden implementations of
// EntityAccessControlHandler::checkAccess(). Entities that have checks that
// need to be done before the hook is invoked should do so by overriding
// this method.
// We grant access to the entity if both of these conditions are met: