You are here

BibciteBibtexServiceProvider.php in Bibliography & Citation 2.0.x

Same filename and directory in other branches
  1. 8 modules/bibcite_bibtex/src/BibciteBibtexServiceProvider.php

File

modules/bibcite_bibtex/src/BibciteBibtexServiceProvider.php
View source
<?php

namespace Drupal\bibcite_bibtex;

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

/**
 * Adds BibTeX as known format.
 */
class BibciteBibtexServiceProvider 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', [
          'bibtex',
          [
            'text/plain',
            'application/x-bibtex',
          ],
        ]);
      }
    }
  }

}

Classes

Namesort descending Description
BibciteBibtexServiceProvider Adds BibTeX as known format.