You are here

class CiteprocPhp in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/BibCiteProcessor/CiteprocPhp.php \Drupal\bibcite\Plugin\BibCiteProcessor\CiteprocPhp

Defines a style provider based on citeproc-php library.

Plugin annotation


@BibCiteProcessor(
  id = "citeproc-php",
  label = @Translation("Citeproc PHP"),
)

Hierarchy

Expanded class hierarchy of CiteprocPhp

File

src/Plugin/BibCiteProcessor/CiteprocPhp.php, line 20

Namespace

Drupal\bibcite\Plugin\BibCiteProcessor
View source
class CiteprocPhp extends BibCiteProcessorBase implements BibCiteProcessorInterface, ContainerFactoryPluginInterface {

  /**
   * Config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this
      ->t('Render citation by citeproc-php library');
  }

  /**
   * {@inheritdoc}
   */
  public function render($data, $csl, $lang) {
    $cite_proc = new CiteProc($csl, $lang);
    if (!$data instanceof \stdClass) {
      $data = json_decode(json_encode($data));
    }
    return $cite_proc
      ->render($data);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BibCiteProcessorBase::getPluginLabel public function Get plugin label markup. Overrides BibCiteProcessorInterface::getPluginLabel
CiteprocPhp::$configFactory protected property Config factory service.
CiteprocPhp::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
CiteprocPhp::getDescription public function Get plugin description markup. Overrides BibCiteProcessorBase::getDescription
CiteprocPhp::render public function Render citation string from CSL values array. Overrides BibCiteProcessorInterface::render
CiteprocPhp::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.