function EntityCacheTagsTestBase::createCacheId

Same name in other branches
  1. 8.9.x core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createCacheId()
  2. 8.9.x core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::createCacheId()
  3. 10 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.

4 calls to EntityCacheTagsTestBase::createCacheId()
BlockContentCacheTagsTest::testBlock in core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php
Tests that the block is cached with the correct contexts and tags.
EntityCacheTagsTestBase::testReferencedEntity in core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
Tests cache tags presence and invalidation of the entity when referenced.
EntityCacheTagsTestBase::verifyRenderCache in core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php
Verify that a given render cache entry exists, with the correct cache tags.
EntityWithUriCacheTagsTestBase::testEntityUri in core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php
Tests cache tags presence and invalidation of the entity at its URI.

File

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

Class

EntityCacheTagsTestBase
Provides helper methods for Entity cache tags tests.

Namespace

Drupal\Tests\system\Functional\Entity

Code

protected function createCacheId(array $keys, array $contexts) {
    $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.