You are here

protected function DataDefinitionNormalizer::normalizeProperties in JSON:API Schema 8

Normalize an array of data definitions.

This normalization process gets an array of properties and an array of properties that are required by name. This is needed by the SchemataSchemaNormalizer, otherwise it would have been placed in DataDefinitionNormalizer.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface[] $items: An array of data definition properties to be normalized.

string $format: Format identifier of the current serialization process.

array $context: Operating context of the serializer.

Return value

array Array containing one or two nested arrays.

  • properties: The array of all normalized properties.
  • required: The array of required properties by name.
1 call to DataDefinitionNormalizer::normalizeProperties()
ComplexDataDefinitionNormalizer::normalize in src/Normalizer/ComplexDataDefinitionNormalizer.php

File

src/Normalizer/DataDefinitionNormalizer.php, line 140

Class

DataDefinitionNormalizer
Normalizer for DataDefinitionInterface instances.

Namespace

Drupal\jsonapi_schema\Normalizer

Code

protected function normalizeProperties(array $items, $format, array $context = []) {
  $normalized = [];
  foreach ($items as $name => $property) {
    $context['name'] = $name;
    $item = $this->serializer
      ->normalize($property, $format, $context);
    if (!empty($item)) {
      $normalized = NestedArray::mergeDeep($normalized, $item);
    }
  }
  return $normalized;
}