class ResponseSubscriber in Commerce Core 8.2
Response subscriber to add the "X-Commerce-Core" header tag.
Hierarchy
- class \Drupal\commerce\EventSubscriber\ResponseSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ResponseSubscriber
1 string reference to 'ResponseSubscriber'
1 service uses ResponseSubscriber
File
- src/
EventSubscriber/ ResponseSubscriber.php, line 12
Namespace
Drupal\commerce\EventSubscriberView source
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\FilterResponseEvent $event
* The event to process.
*/
public function onResponse(FilterResponseEvent $event) {
if (!$event
->isMasterRequest()) {
return;
}
$response = $event
->getResponse();
$response->headers
->set('X-Commerce-Core', '2');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ResponseSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ResponseSubscriber:: |
public | function | Sets extra X-Commerce-Core header on successful responses. |