function 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.
13 calls to Cache::mergeContexts()
- ArgumentPluginBase::getCacheContexts in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php - The cache contexts associated with this object.
- BlockViewBuilder::viewMultiple in core/
modules/ block/ src/ BlockViewBuilder.php - Builds the render array for the provided entities.
- CacheableMetadata::merge in core/
lib/ Drupal/ Core/ Cache/ CacheableMetadata.php - Merges the values of another CacheableMetadata object with this one.
- ContextAwarePluginTrait::getCacheContexts in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php - ExposedFormPluginBase::getCacheContexts in core/
modules/ views/ src/ Plugin/ views/ exposed_form/ ExposedFormPluginBase.php - The cache contexts associated with this object.
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;
}