You are here

public function ReferenceNormalizerBase::normalize in Bibliography & Citation 2.0.x

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

Overrides ComplexDataNormalizer::normalize

1 call to ReferenceNormalizerBase::normalize()
CslReferenceNormalizer::normalize in modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php
2 methods override ReferenceNormalizerBase::normalize()
BibtexReferenceNormalizer::normalize in modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php
CslReferenceNormalizer::normalize in modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php

File

modules/bibcite_entity/src/Normalizer/ReferenceNormalizerBase.php, line 349

Class

ReferenceNormalizerBase
Base normalizer class for bibcite formats.

Namespace

Drupal\bibcite_entity\Normalizer

Code

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

  /** @var \Drupal\bibcite_entity\Entity\ReferenceInterface $reference */
  $attributes = [];
  $attributes[$this->typeKey] = $this
    ->convertEntityType($reference
    ->bundle(), $format);
  if ($keywords = $this
    ->extractKeywords($reference
    ->get('keywords'))) {
    $attributes[$this->keywordKey] = $keywords;
  }
  if ($authors = $this
    ->extractAuthors($reference
    ->get('author'))) {
    $attributes[$this->contributorKey] = $authors;
  }
  $attributes += $this
    ->extractFields($reference, $format);
  return $attributes;
}