function FieldItemNormalizer::normalize

1 call to FieldItemNormalizer::normalize()
EntityReferenceItemNormalizer::normalize in core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php
1 method overrides FieldItemNormalizer::normalize()
EntityReferenceItemNormalizer::normalize in core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php

File

core/modules/hal/src/Normalizer/FieldItemNormalizer.php, line 27

Class

FieldItemNormalizer
Converts the Drupal field item object structure to HAL array structure.

Namespace

Drupal\hal\Normalizer

Code

public function normalize($field_item, $format = NULL, array $context = []) {
  // The values are wrapped in an array, and then wrapped in another array
  // keyed by field name so that field items can be merged by the
  // FieldNormalizer. This is necessary for the EntityReferenceItemNormalizer
  // to be able to place values in the '_links' array.
  $field = $field_item->getParent();
  return [
    $field->getName() => [
      $this->normalizedFieldValues($field_item, $format, $context),
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.