<?php/**
* @file
* Contains \Drupal\hal\HalSubscriber.
*/namespaceDrupal\hal;
useSymfony\Component\HttpKernel\KernelEvents;
useSymfony\Component\HttpKernel\Event\GetResponseEvent;
useSymfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Subscribes to the kernel request event to add HAL media types.
*/class HalSubscriberimplements EventSubscriberInterface {
/**
* Registers HAL formats with the Request class.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event to process.
*/
public functiononKernelRequest(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 functiongetSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array(
'onKernelRequest',
40,
);
return$events;
}
}