You are here

class ViewsTestCacheContext in Drupal 9

Same name and namespace in other branches
  1. 8 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

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

Namesort descending Modifiers Type Description Overrides
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