Version 1
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / filter / ViewsTestCacheContextFilter.php
diff --git a/web/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php b/web/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/ViewsTestCacheContextFilter.php
new file mode 100644 (file)
index 0000000..bb9ac44
--- /dev/null
@@ -0,0 +1,31 @@
+<?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;
+  }
+
+}