You are here

BibciteEndnoteServiceProvider.php in Bibliography & Citation 8

Same filename and directory in other branches
  1. 2.0.x modules/bibcite_endnote/src/BibciteEndnoteServiceProvider.php

File

modules/bibcite_endnote/src/BibciteEndnoteServiceProvider.php
View source
<?php

namespace Drupal\bibcite_endnote;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;

/**
 * Adds EndNote as known format.
 */
class BibciteEndnoteServiceProvider implements ServiceModifierInterface {

  /**
   * {@inheritdoc}
   */
  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',
          ],
        ]);
      }
    }
  }

}

Classes

Namesort descending Description
BibciteEndnoteServiceProvider Adds EndNote as known format.