class ViewsTestCacheContext
Test cache context which uses a dynamic context coming from state.
Cache context ID: 'views_test_cache_context'.
Hierarchy
- class \Drupal\views_test_data\Cache\ViewsTestCacheContext implements \Drupal\Core\Cache\Context\CacheContextInterface
 
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\CacheView 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
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | 
|---|---|---|---|---|
| ViewsTestCacheContext::getCacheableMetadata | public | function | Gets the cacheability metadata for the context. | Overrides CacheContextInterface::getCacheableMetadata | 
| ViewsTestCacheContext::getContext | public | function | Returns the string representation of the cache context. | Overrides CacheContextInterface::getContext | 
| ViewsTestCacheContext::getLabel | public static | function | Returns the label of the cache context. | Overrides CacheContextInterface::getLabel | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.