You are here

public function DataReferenceDefinitionNormalizer::normalize in Schemata 8

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

Overrides DataDefinitionNormalizer::normalize

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

File

schemata_json_schema/src/Normalizer/json/DataReferenceDefinitionNormalizer.php, line 48

Class

DataReferenceDefinitionNormalizer
Normalizer for Entity References.

Namespace

Drupal\schemata_json_schema\Normalizer\json

Code

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

  /* @var $entity \Drupal\Core\TypedData\DataReferenceDefinitionInterface */
  try {
    $is_valid = $this
      ->validateEntity($entity);
  } catch (PluginNotFoundException $exception) {
    $is_valid = FALSE;
  }

  // DataDefinitionNormalizer::normalize() results in extraneous structures
  // added to the schema for this field element (e.g., entity)
  return $is_valid ? $this
    ->extractPropertyData($entity, $context) : [];
}