
| Current Path : /var/www/html/rocksensor3/web/core/lib/Drupal/Core/EventSubscriber/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor3/web/core/lib/Drupal/Core/EventSubscriber/ResponseGeneratorSubscriber.php |
<?php
namespace Drupal\Core\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Response subscriber to add X-Generator header tag.
*/
class ResponseGeneratorSubscriber implements EventSubscriberInterface {
/**
* Sets extra X-Generator header on successful responses.
*
* @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* The event to process.
*/
public function onRespond(ResponseEvent $event) {
if (!$event->isMainRequest()) {
return;
}
$response = $event->getResponse();
// Set the generator in the HTTP header.
[$version] = explode('.', \Drupal::VERSION, 2);
$response->headers->set('X-Generator', 'Drupal ' . $version . ' (https://www.drupal.org)');
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
$events[KernelEvents::RESPONSE][] = ['onRespond'];
return $events;
}
}