{% extends "base/class.php.twig" %}

{% block file_path %}
\Drupal\{{module}}\{{ class }}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\EventSubscriber;
{% endblock %}

{% block use_class %}
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\Event;
{% endblock %}

{% block class_declaration %}
/**
 * Class {{ class }}.
 */
class {{ class }} implements EventSubscriberInterface {% endblock %}

{% block class_construct %}

  /**
   * Constructs a new {{ class }} object.
   */
  public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
{{ serviceClassInitialization(services) }}
  }

{% endblock %}

{% block class_methods %}
  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
{% for event_name, callback in events %}
    $events['{{ event_name }}'] = ['{{ callback }}'];
{% endfor %}

    return $events;
  }

{% for event_name, callback in events %}
  /**
   * This method is called whenever the {{ event_name }} event is
   * dispatched.
   *
   * @param GetResponseEvent $event
   */
  public function {{ callback }}(Event $event) {
    drupal_set_message('Event {{ event_name }} thrown by Subscriber in module {{ module }}.', 'status', TRUE);
  }
{% endfor %}
{% endblock %}
