
| Current Path : /var/www/html/store/web/modules/contrib/commerce/src/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/store/web/modules/contrib/commerce/src/EventSubscriber/ResponseSubscriber.php |
<?php
namespace Drupal\commerce\EventSubscriber;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Response subscriber to add the "X-Commerce-Core" header tag.
*/
class ResponseSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::RESPONSE][] = ['onResponse'];
return $events;
}
/**
* Sets extra X-Commerce-Core header on successful responses.
*
* @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* The event to process.
*/
public function onResponse(ResponseEvent $event) {
if (!$event->isMainRequest()) {
return;
}
$response = $event->getResponse();
$response->headers->set('X-Commerce-Core', '2');
}
}