You are here

public function FilterPluginBase::getCacheContexts in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::getCacheContexts()
  2. 10 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::getCacheContexts()

The cache contexts associated with this object.

These identify a specific variation/representation of the object.

Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.

Return value

string[] An array of cache context tokens, used to generate a cache ID.

Overrides CacheableDependencyInterface::getCacheContexts

See also

\Drupal\Core\Cache\Context\CacheContextsManager::convertTokensToKeys()

7 calls to FilterPluginBase::getCacheContexts()
Access::getCacheContexts in core/modules/node/src/Plugin/views/filter/Access.php
The cache contexts associated with this object.
Current::getCacheContexts in core/modules/user/src/Plugin/views/filter/Current.php
The cache contexts associated with this object.
ModerationStateFilter::getCacheContexts in core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php
The cache contexts associated with this object.
Status::getCacheContexts in core/modules/node/src/Plugin/views/filter/Status.php
The cache contexts associated with this object.
Status::getCacheContexts in core/modules/media/src/Plugin/views/filter/Status.php
The cache contexts associated with this object.

... See full list

7 methods override FilterPluginBase::getCacheContexts()
Access::getCacheContexts in core/modules/node/src/Plugin/views/filter/Access.php
The cache contexts associated with this object.
Current::getCacheContexts in core/modules/user/src/Plugin/views/filter/Current.php
The cache contexts associated with this object.
ModerationStateFilter::getCacheContexts in core/modules/content_moderation/src/Plugin/views/filter/ModerationStateFilter.php
The cache contexts associated with this object.
Status::getCacheContexts in core/modules/node/src/Plugin/views/filter/Status.php
The cache contexts associated with this object.
Status::getCacheContexts in core/modules/media/src/Plugin/views/filter/Status.php
The cache contexts associated with this object.

... See full list

File

core/modules/views/src/Plugin/views/filter/FilterPluginBase.php, line 1573

Class

FilterPluginBase
Base class for Views filters handler plugins.

Namespace

Drupal\views\Plugin\views\filter

Code

public function getCacheContexts() {
  $cache_contexts = [];

  // An exposed filter allows the user to change a view's filters. They accept
  // input from GET parameters, which are part of the URL. Hence a view with
  // an exposed filter is cacheable per URL.
  if ($this
    ->isExposed()) {
    $cache_contexts[] = 'url';
  }
  return $cache_contexts;
}