You are here

public function CslReferenceNormalizer::normalize in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php \Drupal\bibcite_entity\Normalizer\CslReferenceNormalizer::normalize()

Overrides ReferenceNormalizerBase::normalize

File

modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php, line 42

Class

CslReferenceNormalizer
Normalizes/denormalizes reference entity to CSL format.

Namespace

Drupal\bibcite_entity\Normalizer

Code

public function normalize($reference, $format = NULL, array $context = []) {

  /** @var \Drupal\bibcite_entity\Entity\ReferenceInterface $reference */
  $attributes = parent::normalize($reference, $format, $context);
  $contributor_key = $this
    ->getContributorKey();
  if (isset($attributes[$contributor_key])) {
    $authors = $attributes[$contributor_key];
    foreach ($authors as $role => $contributors) {
      $attributes[$role] = $contributors;
    }
  }
  return $attributes;
}