function ViewExecutable::addCacheContext

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::addCacheContext()
  2. 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::addCacheContext()
  3. 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::addCacheContext()

Expands the list of used cache contexts for the view.

Parameters

string $cache_context: The additional cache context.

Return value

$this

File

core/modules/views/src/ViewExecutable.php, line 563

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function addCacheContext($cache_context) {
    $this->element['#cache']['contexts'][] = $cache_context;
    return $this;
}

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