function PrimitiveDataNormalizer::getNormalizationSchema

Same name and namespace in other branches
  1. 11.x core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php \Drupal\serialization\Normalizer\PrimitiveDataNormalizer::getNormalizationSchema()

Overrides SchematicNormalizerTrait::getNormalizationSchema

File

core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php, line 45

Class

PrimitiveDataNormalizer
Converts primitive data objects to their casted values.

Namespace

Drupal\serialization\Normalizer

Code

public function getNormalizationSchema(mixed $object, array $context = []) : array {
  $nullable = !$object instanceof TypedDataInterface || !$object->getDataDefinition()
    ->isRequired();
  return $this->getJsonSchemaForMethod($object, 'getCastedValue', [
    '$comment' => 'Unable to provide schema, no type specified.',
  ], $nullable);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.