ViewsTestCacheContextFilter.php

Same filename and directory in other branches
  1. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php
  2. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php
  3. 11.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php

Namespace

Drupal\views_test_data\Plugin\views\filter

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php

View source
<?php

namespace Drupal\views_test_data\Plugin\views\filter;

use Drupal\views\Plugin\views\filter\FilterPluginBase;

/**
 * @ViewsFilter("views_test_test_cache_context")
 */
class ViewsTestCacheContextFilter extends FilterPluginBase {
    
    /**
     * {@inheritdoc}
     */
    public function query() {
        $this->value = \Drupal::state()->get('views_test_cache_context', 'George');
        parent::query();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheContexts() {
        $cache_contexts = parent::getCacheContexts();
        $cache_contexts[] = 'views_test_cache_context';
        return $cache_contexts;
    }

}

Classes

Title Deprecated Summary
ViewsTestCacheContextFilter Plugin annotation @ViewsFilter("views_test_test_cache_context");

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