Version 1
[yaffs-website] / web / core / modules / hal / src / HalServiceProvider.php
1 <?php
2
3 namespace Drupal\hal;
4
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\Core\DependencyInjection\ServiceModifierInterface;
7
8 /**
9  * Adds hal+json as known format.
10  */
11 class HalServiceProvider implements ServiceModifierInterface {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function alter(ContainerBuilder $container) {
17     if ($container->has('http_middleware.negotiation') && is_a($container->getDefinition('http_middleware.negotiation')->getClass(), '\Drupal\Core\StackMiddleware\NegotiationMiddleware', TRUE)) {
18       $container->getDefinition('http_middleware.negotiation')->addMethodCall('registerFormat', ['hal_json', ['application/hal+json']]);
19     }
20   }
21
22 }