You are here

protected function EntityReferenceItemNormalizer::normalizedFieldValues in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php \Drupal\hal\Normalizer\EntityReferenceItemNormalizer::normalizedFieldValues()

Normalizes field values for an item.

Parameters

\Drupal\Core\Field\FieldItemInterface $field_item: The field item instance.

string|null $format: The normalization format.

array $context: The context passed into the normalizer.

Return value

array An array of field item values, keyed by property name.

Overrides FieldItemNormalizer::normalizedFieldValues

File

core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php, line 161

Class

EntityReferenceItemNormalizer
Converts the Drupal entity reference item object to HAL array structure.

Namespace

Drupal\hal\Normalizer

Code

protected function normalizedFieldValues(FieldItemInterface $field_item, $format, array $context) {

  // Normalize root reference values here so we don't need to deal with hal's
  // nested data structure for field items. This will be called from
  // \Drupal\hal\Normalizer\FieldItemNormalizer::normalize. Which will only
  // be called from this class for entities that are not fieldable.
  $normalized = parent::normalizedFieldValues($field_item, $format, $context);
  $this
    ->normalizeRootReferenceValue($normalized, $field_item);
  return $normalized;
}