Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / templates / module / src / cache-context.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\{{ class }}.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\CacheContext;
9 {% endblock %}
10
11 {% block use_class %}
12 use Drupal\Core\Cache\CacheableMetadata;
13 use Drupal\Core\Cache\Context\CacheContextInterface;
14 {% endblock %}
15
16 {% block class_declaration %}
17 /**
18 * Class {{ class }}.
19 *
20 * @package Drupal\{{module}}
21 */
22 class {{ class }} implements CacheContextInterface {% endblock %}
23
24 {% block class_construct %}
25
26   /**
27    * Constructs a new {{ class }} object.
28    */
29   public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
30   {{ serviceClassInitialization(services) }}
31   }
32
33 {% endblock %}
34
35 {% block class_methods %}
36   /**
37   * {@inheritdoc}
38   */
39   public static function getLabel() {
40     drupal_set_message('Lable of cache context');
41   }
42
43   /**
44   * {@inheritdoc}
45   */
46   public function getContext() {
47     // Actual logic of context variation will lie here.
48   }
49
50   /**
51   * {@inheritdoc}
52   */
53   public function getCacheableMetadata() {
54     return new CacheableMetadata();
55   }
56 {% endblock %}