CsvSubscriber.php in CSV Serialization 8.2
Same filename and directory in other branches
Namespace
Drupal\csv_serialization\EventSubscriberFile
src/EventSubscriber/CsvSubscriber.phpView source
<?php
namespace Drupal\csv_serialization\EventSubscriber;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Event subscriber for adding CSV content types to the request.
*/
class CsvSubscriber implements EventSubscriberInterface {
/**
* Register content type formats on the request object.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process.
*/
public function onKernelRequest(GetResponseEvent $event) {
$event
->getRequest()
->setFormat('csv', [
'text/csv',
]);
}
/**
* Implements \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents().
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'onKernelRequest',
];
return $events;
}
}
Classes
Name![]() |
Description |
---|---|
CsvSubscriber | Event subscriber for adding CSV content types to the request. |