You are here

private function BibtexReferenceNormalizer::extractContributors in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php \Drupal\bibcite_bibtex\Normalizer\BibtexReferenceNormalizer::extractContributors()

Extract contributors values from field.

Parameters

\Drupal\Core\Field\FieldItemListInterface $field_item_list: List of field items.

Return value

array Contributors in BibTeX format.

1 call to BibtexReferenceNormalizer::extractContributors()
BibtexReferenceNormalizer::normalize in modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php

File

modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php, line 93

Class

BibtexReferenceNormalizer
Normalizes/denormalizes reference entity to BibTeX format.

Namespace

Drupal\bibcite_bibtex\Normalizer

Code

private function extractContributors(FieldItemListInterface $field_item_list) {
  $contributors = [];
  foreach ($field_item_list as $field) {
    $role = $field
      ->get('role')
      ->getValue() === 'editor' ? 'editor' : 'author';
    $contributors[$role][] = $field->entity
      ->getName();
  }
  return $contributors;
}