You are here

protected function BibtexEncoder::buildEntry 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::buildEntry()

Build BibTeX entry string.

Parameters

array $data: Array of BibTeX values.

Return value

string Formatted BibTeX string.

1 call to BibtexEncoder::buildEntry()
BibtexEncoder::encode in modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php

File

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

Class

BibtexEncoder
BibTeX format encoder.

Namespace

Drupal\bibcite_bibtex\Encoder

Code

protected function buildEntry(array $data) {
  if (empty($data['reference'])) {
    $data['reference'] = $data['type'];
  }

  // Hotfix "editor" field so it behaves the same as "author" field.
  if (isset($data['editor'])) {
    $data['editor'] = implode(' and ', $data['editor']);
  }
  $entry = $this
    ->buildStart($data['type'], $data['reference']);
  unset($data['type']);
  unset($data['reference']);
  foreach ($data as $key => $value) {
    $entry .= $this
      ->buildLine($key, $value);
  }
  $entry .= $this
    ->buildEnd();
  return $entry;
}