You are here

DOI.php in Bibliography & Citation 2.0.x

Same filename and directory in other branches
  1. 8 modules/bibcite_entity/src/Plugin/bibcite/link/DOI.php

File

modules/bibcite_entity/src/Plugin/bibcite/link/DOI.php
View source
<?php

namespace Drupal\bibcite_entity\Plugin\bibcite\link;

use Drupal\bibcite_entity\Entity\ReferenceInterface;
use Drupal\bibcite_entity\Plugin\BibciteLinkPluginBase;
use Drupal\Core\Url;

/**
 * Build DOI lookup link.
 *
 * @BibciteLink(
 *   id = "doi",
 *   label = @Translation("DOI"),
 * )
 */
class DOI extends BibciteLinkPluginBase {

  /**
   * {@inheritdoc}
   */
  public function buildUrl(ReferenceInterface $reference) {
    $doi_field = $reference
      ->get('bibcite_doi');
    if (!$doi_field
      ->isEmpty()) {
      return Url::fromUri("http://dx.doi.org/{$doi_field->value}");
    }
    return NULL;
  }

}

Classes

Namesort descending Description
DOI Build DOI lookup link.