3 namespace Drupal\{{ machine_name }}\Cache\Context;
5 use Drupal\Core\Cache\CacheableMetadata;
6 use Drupal\Core\Cache\Context\{{ interface }};
8 use Drupal\Core\Cache\Context\{{ base_class }};
12 * Defines the ExampleCacheContext service.
14 * Cache context ID: '{{ context_id }}'.
17 * Check out the core/lib/Drupal/Core/Cache/Context directory for examples of
18 * cache contexts provided by Drupal core.
20 class {{ class }} {% if base_class %}extends {{ base_class }} {% endif %}implements {{ interface }} {
25 public static function getLabel() {
26 return t('{{ context_label }}');
32 public function getContext({% if calculated %}$parameter = NULL{% endif %}) {
33 // @DCG: Define the cache context here.
34 $context = 'some_string_value';
41 public function getCacheableMetadata({% if calculated %}$parameter = NULL{% endif %}) {
42 return new CacheableMetadata();