function TypedDataNormalizer::normalize
Same name in other branches
- 9 core/modules/serialization/src/Normalizer/TypedDataNormalizer.php \Drupal\serialization\Normalizer\TypedDataNormalizer::normalize()
- 8.9.x core/modules/serialization/src/Normalizer/TypedDataNormalizer.php \Drupal\serialization\Normalizer\TypedDataNormalizer::normalize()
- 11.x core/modules/serialization/src/Normalizer/TypedDataNormalizer.php \Drupal\serialization\Normalizer\TypedDataNormalizer::normalize()
File
-
core/
modules/ serialization/ src/ Normalizer/ TypedDataNormalizer.php, line 15
Class
- TypedDataNormalizer
- Converts typed data objects to arrays.
Namespace
Drupal\serialization\NormalizerCode
public function normalize($object, $format = NULL, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
$this->addCacheableDependency($context, $object);
$value = $object->getValue();
// Support for stringable value objects: avoid numerous custom normalizers.
if (is_object($value) && method_exists($value, '__toString')) {
$value = (string) $value;
}
return $value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.