Version 1
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Cache / ViewsTestCacheContext.php
1 <?php
2
3 namespace Drupal\views_test_data\Cache;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Cache\Context\CacheContextInterface;
7
8 /**
9  * Test cache context which uses a dynamic context coming from state.
10  *
11  * Cache context ID: 'views_test_cache_context'.
12  */
13 class ViewsTestCacheContext implements CacheContextInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static function getLabel() {
19     return t('Views test cache context');
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function getContext() {
26     return \Drupal::state()->get('views_test_cache_context', 'George');
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function getCacheableMetadata() {
33     return new CacheableMetadata();
34   }
35
36 }