ResponseGeneratorSubscriber.php in Drupal 10
File
core/lib/Drupal/Core/EventSubscriber/ResponseGeneratorSubscriber.php
View source
<?php
namespace Drupal\Core\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ResponseGeneratorSubscriber implements EventSubscriberInterface {
public function onRespond(ResponseEvent $event) {
if (!$event
->isMainRequest()) {
return;
}
$response = $event
->getResponse();
[
$version,
] = explode('.', \Drupal::VERSION, 2);
$response->headers
->set('X-Generator', 'Drupal ' . $version . ' (https://www.drupal.org)');
}
public static function getSubscribedEvents() : array {
$events[KernelEvents::RESPONSE][] = [
'onRespond',
];
return $events;
}
}