class Subscriber in Excel Serialization 8
Event subscriber for adding XLS content to the request.
Hierarchy
- class \Drupal\xls_serialization\EventSubscriber\Subscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of Subscriber
1 file declares its use of Subscriber
- SubscriberTest.php in tests/
src/ Unit/ EventSubscriber/ SubscriberTest.php
1 string reference to 'Subscriber'
1 service uses Subscriber
File
- src/
EventSubscriber/ Subscriber.php, line 12
Namespace
Drupal\xls_serialization\EventSubscriberView source
class Subscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'onKernelRequest',
];
return $events;
}
/**
* Register content formats on the request object.
*
* @param Symfony\Component\HttpKernel\Event\RequestEvent $event
* The event to get the request object to register on.
*/
public function onKernelRequest(RequestEvent $event) {
$event
->getRequest()
->setFormat('xls', [
'application/vnd.ms-excel',
]);
$event
->getRequest()
->setFormat('xlsx', [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Subscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
Subscriber:: |
public | function | Register content formats on the request object. |