Initial Drupal 11 with DDEV setup
This commit is contained in:
62
vendor/chi-teck/drupal-code-generator/templates/Service/_event-subscriber/event-subscriber.twig
vendored
Normal file
62
vendor/chi-teck/drupal-code-generator/templates/Service/_event-subscriber/event-subscriber.twig
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{% import '@lib/di.twig' as di %}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }}\EventSubscriber;
|
||||
|
||||
{% apply sort_namespaces %}
|
||||
{% if services %}
|
||||
{{ di.use(services) }}
|
||||
{% endif %}
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
{% endapply %}
|
||||
|
||||
/**
|
||||
* @todo Add description for this subscriber.
|
||||
*/
|
||||
final class {{ class }} implements EventSubscriberInterface {
|
||||
{% if services %}
|
||||
|
||||
/**
|
||||
* Constructs {{ class|article }} object.
|
||||
*/
|
||||
public function __construct(
|
||||
{{ di.signature(services) }}
|
||||
) {}
|
||||
{% endif %}
|
||||
|
||||
/**
|
||||
* Kernel request event handler.
|
||||
*/
|
||||
public function onKernelRequest(RequestEvent $event): void {
|
||||
// @todo Place your code here.
|
||||
{% if SUT_TEST %}
|
||||
$this->messenger->addStatus(__FUNCTION__);
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kernel response event handler.
|
||||
*/
|
||||
public function onKernelResponse(ResponseEvent $event): void {
|
||||
// @todo Place your code here.
|
||||
{% if SUT_TEST %}
|
||||
$this->messenger->addStatus(__FUNCTION__);
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents(): array {
|
||||
return [
|
||||
KernelEvents::REQUEST => ['onKernelRequest'],
|
||||
KernelEvents::RESPONSE => ['onKernelResponse'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
9
vendor/chi-teck/drupal-code-generator/templates/Service/_event-subscriber/services.twig
vendored
Normal file
9
vendor/chi-teck/drupal-code-generator/templates/Service/_event-subscriber/services.twig
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{% import '@lib/di.twig' as di %}
|
||||
services:
|
||||
{{ machine_name }}.event_subscriber:
|
||||
class: Drupal\{{ machine_name }}\EventSubscriber\{{ class }}
|
||||
{% if services %}
|
||||
arguments: [{{ di.arguments(services) }}]
|
||||
{% endif %}
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
Reference in New Issue
Block a user