Mercurial > hg > isophonics-drupal-site
comparison core/modules/hal/src/HalServiceProvider.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 } |