Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / serialization / src / Normalizer / TypedDataNormalizer.php
index 60ce7d08f696547ed1fb4ab8211aeb80fc715e19..690fd8db252e0f342281f3fac1cd851b46212502 100644 (file)
@@ -18,7 +18,13 @@ class TypedDataNormalizer extends NormalizerBase {
    * {@inheritdoc}
    */
   public function normalize($object, $format = NULL, array $context = []) {
-    return $object->getValue();
+    $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;
   }
 
 }