You are here

public function BibciteEndnoteServiceProvider::alter in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_endnote/src/BibciteEndnoteServiceProvider.php \Drupal\bibcite_endnote\BibciteEndnoteServiceProvider::alter()

Modifies existing service definitions.

Parameters

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

Overrides ServiceModifierInterface::alter

File

modules/bibcite_endnote/src/BibciteEndnoteServiceProvider.php, line 16

Class

BibciteEndnoteServiceProvider
Adds EndNote as known format.

Namespace

Drupal\bibcite_endnote

Code

public function alter(ContainerBuilder $container) {
  if ($container
    ->has('http_middleware.negotiation')) {
    $definition = $container
      ->getDefinition('http_middleware.negotiation');
    if (is_a($definition
      ->getClass(), '\\Drupal\\Core\\StackMiddleware\\NegotiationMiddleware', TRUE)) {
      $definition
        ->addMethodCall('registerFormat', [
        'endnote7',
        [
          'text/xml',
          'application/x-endnote-refer',
        ],
      ]);
      $definition
        ->addMethodCall('registerFormat', [
        'endnote8',
        [
          'text/xml',
          'application/x-endnote-refer',
        ],
      ]);
      $definition
        ->addMethodCall('registerFormat', [
        'tagged',
        [
          'text/plain',
          'application/x-endnote-refer',
        ],
      ]);
    }
  }
}