ResponseGeneratorSubscriber.php in Drupal 9
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();
list($version) = explode('.', \Drupal::VERSION, 2);
$response->headers
->set('X-Generator', 'Drupal ' . $version . ' (https://www.drupal.org)');
}
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = [
'onRespond',
];
return $events;
}
}