You are here

public function AcquiaContentHubServiceProvider::alter in Acquia Content Hub 8

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceProviderBase::alter

File

src/AcquiaContentHubServiceProvider.php, line 21

Class

AcquiaContentHubServiceProvider
Make sure it exposes the acquia_contenthub_cdf format as json.

Namespace

Drupal\acquia_contenthub

Code

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', [
      'acquia_contenthub_cdf',
      [
        'application/json',
      ],
    ]);
  }
}