You are here

public function CiteprocPhp::render 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::render()

Render citation string from CSL values array.

Parameters

array|\stdClass $data: CSL values array or object.

string $csl: Citation style (CSL) content.

string $lang: Citation language.

Return value

string Rendered citation.

Overrides BibCiteProcessorInterface::render

File

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

Class

CiteprocPhp
Defines a style provider based on citeproc-php library.

Namespace

Drupal\bibcite\Plugin\BibCiteProcessor

Code

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);
}