class ViewsTestCacheContext

Same name in other branches
  1. 8.9.x core/modules/views/tests/modules/views_test_data/src/Cache/ViewsTestCacheContext.php \Drupal\views_test_data\Cache\ViewsTestCacheContext
  2. 10 core/modules/views/tests/modules/views_test_data/src/Cache/ViewsTestCacheContext.php \Drupal\views_test_data\Cache\ViewsTestCacheContext
  3. 11.x core/modules/views/tests/modules/views_test_data/src/Cache/ViewsTestCacheContext.php \Drupal\views_test_data\Cache\ViewsTestCacheContext

Test cache context which uses a dynamic context coming from state.

Cache context ID: 'views_test_cache_context'.

Hierarchy

Expanded class hierarchy of ViewsTestCacheContext

1 string reference to 'ViewsTestCacheContext'
views_test_data.services.yml in core/modules/views/tests/modules/views_test_data/views_test_data.services.yml
core/modules/views/tests/modules/views_test_data/views_test_data.services.yml
1 service uses ViewsTestCacheContext
cache_context.views_test_cache_context in core/modules/views/tests/modules/views_test_data/views_test_data.services.yml
Drupal\views_test_data\Cache\ViewsTestCacheContext

File

core/modules/views/tests/modules/views_test_data/src/Cache/ViewsTestCacheContext.php, line 13

Namespace

Drupal\views_test_data\Cache
View source
class ViewsTestCacheContext implements CacheContextInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Views test cache context');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return \Drupal::state()->get('views_test_cache_context', 'George');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata() {
        return new CacheableMetadata();
    }

}

Members


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