3 namespace Drupal\serialization\Normalizer;
6 * Converts typed data objects to arrays.
8 class TypedDataNormalizer extends NormalizerBase {
11 * The interface or class that this Normalizer supports.
15 protected $supportedInterfaceOrClass = 'Drupal\Core\TypedData\TypedDataInterface';
20 public function normalize($object, $format = NULL, array $context = []) {
21 $this->addCacheableDependency($context, $object);
22 $value = $object->getValue();
23 // Support for stringable value objects: avoid numerous custom normalizers.
24 if (is_object($value) && method_exists($value, '__toString')) {
25 $value = (string) $value;