You are here

PubMed.php in Bibliography & Citation 8

Same filename and directory in other branches
  1. 2.0.x modules/bibcite_entity/src/Plugin/bibcite/link/PubMed.php

File

modules/bibcite_entity/src/Plugin/bibcite/link/PubMed.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 PubMed lookup link.
 *
 * @BibciteLink(
 *   id = "pubmed",
 *   label = @Translation("PubMed"),
 * )
 */
class PubMed extends BibciteLinkPluginBase {

  /**
   * {@inheritdoc}
   */
  public function buildUrl(ReferenceInterface $reference) {
    $pmid_field = $reference
      ->get('bibcite_pmid');
    if (!$pmid_field
      ->isEmpty()) {
      return Url::fromUri("https://www.ncbi.nlm.nih.gov/pubmed/{$pmid_field->value}?dopt=Abstract");
    }
    return NULL;
  }

}

Classes

Namesort descending Description
PubMed Build PubMed lookup link.