You are here

class CsvSubscriber in CSV Serialization 8

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/CsvSubscriber.php \Drupal\csv_serialization\EventSubscriber\CsvSubscriber

Event subscriber for adding CSV content types to the request.

Hierarchy

  • class \Drupal\csv_serialization\EventSubscriber\CsvSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of CsvSubscriber

1 string reference to 'CsvSubscriber'
csv_serialization.services.yml in ./csv_serialization.services.yml
csv_serialization.services.yml
1 service uses CsvSubscriber
csv_serialization.csvsubscriber in ./csv_serialization.services.yml
Drupal\csv_serialization\EventSubscriber\CsvSubscriber

File

src/EventSubscriber/CsvSubscriber.php, line 12

Namespace

Drupal\csv_serialization\EventSubscriber
View source
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;
  }

}

Members