Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / templates / module / src / event-subscriber.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}}\EventSubscriber;
9 {% endblock %}
10
11 {% block use_class %}
12 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
13 use Symfony\Component\EventDispatcher\Event;
14 {% endblock %}
15
16 {% block class_declaration %}
17 /**
18  * Class {{ class }}.
19  *
20  * @package Drupal\{{module}}
21  */
22 class {{ class }} implements EventSubscriberInterface {% 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   static function getSubscribedEvents() {
40 {% for event_name, callback in events %}
41     $events['{{ event_name }}'] = ['{{ callback }}'];
42 {% endfor %}
43
44     return $events;
45   }
46
47 {% for event_name, callback in events %}
48   /**
49    * This method is called whenever the {{ event_name }} event is
50    * dispatched.
51    *
52    * @param GetResponseEvent $event
53    */
54   public function {{ callback }}(Event $event) {
55     drupal_set_message('Event {{ event_name }} thrown by Subscriber in module {{ module }}.', 'status', TRUE);
56   }
57 {% endfor %}
58 {% endblock %}