You are here

public function BibtexEncoder::encode in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php \Drupal\bibcite_bibtex\Encoder\BibtexEncoder::encode()

File

modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php, line 128

Class

BibtexEncoder
BibTeX format encoder.

Namespace

Drupal\bibcite_bibtex\Encoder

Code

public function encode($data, $format, array $context = []) {
  if (isset($data['type'])) {
    $data = [
      $data,
    ];
  }
  $data = array_map(function ($raw) {
    return $this
      ->buildEntry($raw);
  }, $data);
  return implode("\n", $data);
}