class HalSubscriber

Subscribes to the kernel request event to add HAL media types.

Hierarchy

Expanded class hierarchy of HalSubscriber

1 string reference to 'HalSubscriber'
hal.services.yml in drupal/core/modules/hal/hal.services.yml
drupal/core/modules/hal/hal.services.yml
1 service uses HalSubscriber

File

drupal/core/modules/hal/lib/Drupal/hal/HalSubscriber.php, line 17
Contains \Drupal\hal\HalSubscriber.

Namespace

Drupal\hal
View source
class HalSubscriber implements EventSubscriberInterface {

  /**
   * Registers HAL formats with the Request class.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The event to process.
   */
  public function onKernelRequest(GetResponseEvent $event) {
    $request = $event
      ->getRequest();
    $request
      ->setFormat('hal_json', 'application/hal+json');
  }

  /**
   * Registers the methods in this class that should be listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array(
      'onKernelRequest',
      40,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HalSubscriber::getSubscribedEvents static function Registers the methods in this class that should be listeners. Overrides EventSubscriberInterface::getSubscribedEvents
HalSubscriber::onKernelRequest public function Registers HAL formats with the Request class.