function EntityCacheTagsTestBase::createCacheId

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::createCacheId()
  2. 8.9.x core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createCacheId()
  3. 8.9.x core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::createCacheId()

Creates a cache ID from a list of cache keys and a set of cache contexts.

Parameters

string[] $keys: A list of cache keys.

string[] $contexts: A set of cache contexts.

Return value

string The cache ID string.

Deprecated

in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3354596

File

core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php, line 627

Class

EntityCacheTagsTestBase
Provides helper methods for Entity cache tags tests.

Namespace

Drupal\Tests\system\Functional\Entity

Code

protected function createCacheId(array $keys, array $contexts) {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3354596', E_USER_DEPRECATED);
    $cid_parts = $keys;
    $contexts = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($contexts);
    $cid_parts = array_merge($cid_parts, $contexts->getKeys());
    return implode(':', $cid_parts);
}

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