3 namespace Drupal\config_override_integration_test\Cache;
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Cache\Context\CacheContextInterface;
9 * A cache context service intended for the config override integration test.
11 * Cache context ID: 'config_override_integration_test'.
13 class ConfigOverrideIntegrationTestCacheContext implements CacheContextInterface {
18 public static function getLabel() {
19 return t('Config override integration test');
25 public function getContext() {
26 // Default to the 'disabled' state.
27 $state = \Drupal::state()->get('config_override_integration_test.enabled', FALSE) ? 'yes' : 'no';
28 return 'config_override_integration_test.' . $state;
34 public function getCacheableMetadata() {
35 // Since this depends on State this can change at any time and is not
37 $metadata = new CacheableMetadata();
38 $metadata->setCacheMaxAge(0);