webapp_json-8.x-1.0-beta3/src/WebappServiceProvider.php
src/WebappServiceProvider.php
<?php
namespace Drupal\webapp;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
/**
* Adds webapp+json as known format.
*/
class WebappServiceProvider implements ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
if ($container->has('http_middleware.negotiation') && is_a($container->getDefinition('http_middleware.negotiation')->getClass(), '\Drupal\Core\StackMiddleware\NegotiationMiddleware', TRUE)) {
$container->getDefinition('http_middleware.negotiation')->addMethodCall('registerFormat', ['webapp_json', ['application/webapp+json']]);
}
}
}
