ViewsTestCacheContextFilter.php in Drupal 9
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;
class ViewsTestCacheContextFilter extends FilterPluginBase {
public function query() {
$this->value = \Drupal::state()
->get('views_test_cache_context', 'George');
parent::query();
}
public function getCacheContexts() {
$cache_contexts = parent::getCacheContexts();
$cache_contexts[] = 'views_test_cache_context';
return $cache_contexts;
}
}