function Cache::mergeContexts
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeContexts()
- 8.9.x core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeContexts()
- 10 core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::mergeContexts()
Merges lists of cache contexts and removes duplicates.
Parameters
list<string> ...$cache_contexts: Cache contexts to merge.
Return value
list<string> The merged list of cache contexts.
50 calls to Cache::mergeContexts()
- ArgumentPluginBase::getCacheContexts in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php - AssertPageCacheContextsAndTagsTrait::assertCacheContexts in core/
modules/ system/ tests/ src/ Functional/ Cache/ AssertPageCacheContextsAndTagsTrait.php - Ensures that some cache contexts are present in the current response.
- AssertViewsCacheTagsTrait::assertViewsCacheTags in core/
modules/ views/ src/ Tests/ AssertViewsCacheTagsTrait.php - Asserts a view's result & render cache items' cache tags.
- AssertViewsCacheTagsTrait::assertViewsCacheTagsFromStaticRenderArray in core/
modules/ views/ src/ Tests/ AssertViewsCacheTagsTrait.php - Asserts a view's result & render cache items' cache tags.
- BlockContentResourceTestBase::getExpectedCacheContexts in core/
modules/ block_content/ tests/ src/ Functional/ Rest/ BlockContentResourceTestBase.php
File
-
core/
lib/ Drupal/ Core/ Cache/ Cache.php, line 28
Class
- Cache
- Helper methods for cache.
Namespace
Drupal\Core\CacheCode
public static function mergeContexts(array ...$cache_contexts) {
$cache_contexts = array_values(array_unique(array_merge(...$cache_contexts)));
assert(\Drupal::service('cache_contexts_manager')->assertValidTokens($cache_contexts), sprintf('Failed to assert that "%s" are valid cache contexts.', implode(', ', $cache_contexts)));
return $cache_contexts;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.