You are here

protected function ReferenceNormalizerBase::extractFields 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::extractFields()

Extract fields values from reference entity.

Parameters

\Drupal\bibcite_entity\Entity\ReferenceInterface $reference: Reference entity object.

string $format: Serializer format.

Return value

array Array of entity values.

5 calls to ReferenceNormalizerBase::extractFields()
BibtexReferenceNormalizer::extractFields in modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php
Extract fields values from reference entity.
EndnoteReferenceNormalizer::extractFields in modules/bibcite_endnote/src/Normalizer/EndnoteReferenceNormalizer.php
Extract fields values from reference entity.
MarcReferenceNormalizer::extractFields in modules/bibcite_marc/src/Normalizer/MarcReferenceNormalizer.php
Extract fields values from reference entity.
ReferenceNormalizerBase::normalize in modules/bibcite_entity/src/Normalizer/ReferenceNormalizerBase.php
Normalizes an object into a set of arrays/scalars.
RISReferenceNormalizer::extractFields in modules/bibcite_ris/src/Normalizer/RISReferenceNormalizer.php
Extract fields values from reference entity.
5 methods override ReferenceNormalizerBase::extractFields()
BibtexReferenceNormalizer::extractFields in modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php
Extract fields values from reference entity.
CslReferenceNormalizer::extractFields in modules/bibcite_entity/src/Normalizer/CslReferenceNormalizer.php
Extract fields values from reference entity.
EndnoteReferenceNormalizer::extractFields in modules/bibcite_endnote/src/Normalizer/EndnoteReferenceNormalizer.php
Extract fields values from reference entity.
MarcReferenceNormalizer::extractFields in modules/bibcite_marc/src/Normalizer/MarcReferenceNormalizer.php
Extract fields values from reference entity.
RISReferenceNormalizer::extractFields in modules/bibcite_ris/src/Normalizer/RISReferenceNormalizer.php
Extract fields values from reference entity.

File

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

Class

ReferenceNormalizerBase
Base normalizer class for bibcite formats.

Namespace

Drupal\bibcite_entity\Normalizer

Code

protected function extractFields(ReferenceInterface $reference, $format) {
  $attributes = [];
  foreach ($this->fieldsMapping[$format] as $format_field => $entity_field) {
    if ($entity_field && $reference
      ->hasField($entity_field) && ($field = $reference
      ->get($entity_field)) && !$field
      ->isEmpty()) {
      $attributes[$format_field] = $this
        ->extractScalar($field);
    }
  }
  return $attributes;
}