Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / config / tests / config_override_integration_test / src / Cache / ConfigOverrideIntegrationTestCacheContext.php
1 <?php
2
3 namespace Drupal\config_override_integration_test\Cache;
4
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Cache\Context\CacheContextInterface;
7
8 /**
9  * A cache context service intended for the config override integration test.
10  *
11  * Cache context ID: 'config_override_integration_test'.
12  */
13 class ConfigOverrideIntegrationTestCacheContext implements CacheContextInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static function getLabel() {
19     return t('Config override integration test');
20   }
21
22   /**
23    * {@inheritdoc}
24    */
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;
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public function getCacheableMetadata() {
35     // Since this depends on State this can change at any time and is not
36     // cacheable.
37     $metadata = new CacheableMetadata();
38     $metadata->setCacheMaxAge(0);
39     return $metadata;
40   }
41
42 }