You are here

BibciteLinkPluginBase.php in Bibliography & Citation 8

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

File

modules/bibcite_entity/src/Plugin/BibciteLinkPluginBase.php
View source
<?php

namespace Drupal\bibcite_entity\Plugin;

use Drupal\bibcite_entity\Entity\ReferenceInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Link;

/**
 * Base class for Link plugins.
 */
abstract class BibciteLinkPluginBase extends PluginBase implements BibciteLinkPluginInterface {

  /**
   * {@inheritdoc}
   */
  public function getLabel() {
    return $this->pluginDefinition['label'];
  }

  /**
   * Build URL object.
   *
   * @param \Drupal\bibcite_entity\Entity\ReferenceInterface $reference
   *   Reference entity object.
   */
  protected function buildUrl(ReferenceInterface $reference) {
  }

  /**
   * {@inheritdoc}
   */
  public function build(ReferenceInterface $reference) {
    if ($url = $this
      ->buildUrl($reference)) {
      return Link::fromTextAndUrl($this
        ->getLabel(), $url)
        ->toRenderable();
    }
    return NULL;
  }

}

Classes

Namesort descending Description
BibciteLinkPluginBase Base class for Link plugins.