You are here

public function ReferenceNormalizerBase::normalize in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x 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
Normalizes an object into a set of arrays/scalars.
2 methods override ReferenceNormalizerBase::normalize()
BibtexReferenceNormalizer::normalize in modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php
Normalizes an object into a set of arrays/scalars.
CslReferenceNormalizer::normalize in modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php
Normalizes an object into a set of arrays/scalars.

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;
}