function ArgumentPluginBase::getCacheContexts

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getCacheContexts()
  2. 10 core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getCacheContexts()
  3. 11.x core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php \Drupal\views\Plugin\views\argument\ArgumentPluginBase::getCacheContexts()

Overrides CacheableDependencyInterface::getCacheContexts

File

core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php, line 1281

Class

ArgumentPluginBase
Base class for argument (contextual filter) handler plugins.

Namespace

Drupal\views\Plugin\views\argument

Code

public function getCacheContexts() {
    $contexts = [];
    // By definition arguments depends on the URL.
    // @todo Once contexts are properly injected into block views we could pull
    //   the information from there.
    $contexts[] = 'url';
    // Asks all subplugins (argument defaults, argument validator and styles).
    if (($plugin = $this->getPlugin('argument_default')) && $plugin instanceof CacheableDependencyInterface) {
        $contexts = Cache::mergeContexts($contexts, $plugin->getCacheContexts());
    }
    if (($plugin = $this->getPlugin('argument_validator')) && $plugin instanceof CacheableDependencyInterface) {
        $contexts = Cache::mergeContexts($contexts, $plugin->getCacheContexts());
    }
    if (($plugin = $this->getPlugin('style')) && $plugin instanceof CacheableDependencyInterface) {
        $contexts = Cache::mergeContexts($contexts, $plugin->getCacheContexts());
    }
    return $contexts;
}

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