You are here

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

Convert format keys to Bibcite entity keys and filter non-mapped.

Parameters

array $data: Array of decoded values.

string $format: Serializer format.

Return value

array Array of decoded values with converted keys.

1 call to ReferenceNormalizerBase::convertKeys()
ReferenceNormalizerBase::denormalize in modules/bibcite_entity/src/Normalizer/ReferenceNormalizerBase.php

File

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

Class

ReferenceNormalizerBase
Base normalizer class for bibcite formats.

Namespace

Drupal\bibcite_entity\Normalizer

Code

protected function convertKeys(array $data, $format) {
  $converted = [];
  foreach ($data as $key => $field) {
    if (!empty($this->fieldsMapping[$format][$key])) {
      $converted_key = empty($this->fieldsMapping[$format][$key]) ? $key : $this->fieldsMapping[$format][$key];
      $converted[$converted_key] = [
        $field,
      ];
    }
  }
  return $converted;
}