You are here

public function ComplexDataDefinitionNormalizer::normalize in Schemata 8

Same name in this branch
  1. 8 schemata_json_schema/src/Normalizer/jsonapi/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\jsonapi\ComplexDataDefinitionNormalizer::normalize()
  2. 8 schemata_json_schema/src/Normalizer/json/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\json\ComplexDataDefinitionNormalizer::normalize()
  3. 8 schemata_json_schema/src/Normalizer/hal/ComplexDataDefinitionNormalizer.php \Drupal\schemata_json_schema\Normalizer\hal\ComplexDataDefinitionNormalizer::normalize()

Overrides DataDefinitionNormalizer::normalize

1 call to ComplexDataDefinitionNormalizer::normalize()
ComplexDataDefinitionNormalizer::normalize in schemata_json_schema/src/Normalizer/hal/ComplexDataDefinitionNormalizer.php
Normalizes an object into a set of arrays/scalars.
1 method overrides ComplexDataDefinitionNormalizer::normalize()
ComplexDataDefinitionNormalizer::normalize in schemata_json_schema/src/Normalizer/hal/ComplexDataDefinitionNormalizer.php
Normalizes an object into a set of arrays/scalars.

File

schemata_json_schema/src/Normalizer/json/ComplexDataDefinitionNormalizer.php, line 29

Class

ComplexDataDefinitionNormalizer
Normalizer for ComplexDataDefinitionInterface.

Namespace

Drupal\schemata_json_schema\Normalizer\json

Code

public function normalize($entity, $format = NULL, array $context = []) {

  /* @var $entity \Drupal\Core\TypedData\ComplexDataDefinitionInterface */
  $context['parent'] = $entity;
  $normalized = $this
    ->extractPropertyData($entity);
  $normalized['type'] = 'object';

  // Retrieve 'properties' and possibly 'required' nested arrays.
  $properties = $this
    ->normalizeProperties($entity
    ->getPropertyDefinitions(), $format, $context);
  $normalized = NestedArray::mergeDeep($normalized, $properties);
  return $normalized;
}