protected function FieldNormalizer::normalizeFieldItems in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Normalizer/FieldNormalizer.php \Drupal\jsonapi\Normalizer\FieldNormalizer::normalizeFieldItems()
Helper function to normalize field items.
Parameters
\Drupal\Core\Field\FieldItemListInterface $field: The field object.
string $format: The format.
array $context: The context array.
Return value
\Drupal\jsonapi\Normalizer\Value\FieldItemNormalizerValue[] The array of normalized field items.
1 call to FieldNormalizer::normalizeFieldItems()
- FieldNormalizer::normalize in src/
Normalizer/ FieldNormalizer.php - Normalizes an object into a set of arrays/scalars.
File
- src/
Normalizer/ FieldNormalizer.php, line 92
Class
- FieldNormalizer
- Converts the Drupal field structure to a JSON API array structure.
Namespace
Drupal\jsonapi\NormalizerCode
protected function normalizeFieldItems(FieldItemListInterface $field, $format, array $context) {
$normalizer_items = [];
if (!$field
->isEmpty()) {
foreach ($field as $field_item) {
$normalizer_items[] = $this->serializer
->normalize($field_item, $format, $context);
}
}
return $normalizer_items;
}