You are here

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'
xls_serialization.services.yml in ./xls_serialization.services.yml
xls_serialization.services.yml
1 service uses Subscriber
xls_serialization.subscriber in ./xls_serialization.services.yml
Drupal\xls_serialization\EventSubscriber\Subscriber

File

src/EventSubscriber/Subscriber.php, line 12

Namespace

Drupal\xls_serialization\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
Subscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
Subscriber::onKernelRequest public function Register content formats on the request object.