class ConfigOverrideIntegrationTestCacheContext

Same name in other branches
  1. 8.9.x core/modules/config/tests/config_override_integration_test/src/Cache/ConfigOverrideIntegrationTestCacheContext.php \Drupal\config_override_integration_test\Cache\ConfigOverrideIntegrationTestCacheContext
  2. 10 core/modules/config/tests/config_override_integration_test/src/Cache/ConfigOverrideIntegrationTestCacheContext.php \Drupal\config_override_integration_test\Cache\ConfigOverrideIntegrationTestCacheContext
  3. 11.x core/modules/config/tests/config_override_integration_test/src/Cache/ConfigOverrideIntegrationTestCacheContext.php \Drupal\config_override_integration_test\Cache\ConfigOverrideIntegrationTestCacheContext

A cache context service intended for the config override integration test.

Cache context ID: 'config_override_integration_test'.

Hierarchy

Expanded class hierarchy of ConfigOverrideIntegrationTestCacheContext

1 string reference to 'ConfigOverrideIntegrationTestCacheContext'
config_override_integration_test.services.yml in core/modules/config/tests/config_override_integration_test/config_override_integration_test.services.yml
core/modules/config/tests/config_override_integration_test/config_override_integration_test.services.yml
1 service uses ConfigOverrideIntegrationTestCacheContext
cache_context.config_override_integration_test in core/modules/config/tests/config_override_integration_test/config_override_integration_test.services.yml
Drupal\config_override_integration_test\Cache\ConfigOverrideIntegrationTestCacheContext

File

core/modules/config/tests/config_override_integration_test/src/Cache/ConfigOverrideIntegrationTestCacheContext.php, line 13

Namespace

Drupal\config_override_integration_test\Cache
View source
class ConfigOverrideIntegrationTestCacheContext implements CacheContextInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Config override integration test');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        // Default to the 'disabled' state.
        $state = \Drupal::state()->get('config_override_integration_test.enabled', FALSE) ? 'yes' : 'no';
        return 'config_override_integration_test.' . $state;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata() {
        // Since this depends on State this can change at any time and is not
        // cacheable.
        $metadata = new CacheableMetadata();
        $metadata->setCacheMaxAge(0);
        return $metadata;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ConfigOverrideIntegrationTestCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
ConfigOverrideIntegrationTestCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
ConfigOverrideIntegrationTestCacheContext::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.