Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / serialization / src / Normalizer / TypedDataNormalizer.php
1 <?php
2
3 namespace Drupal\serialization\Normalizer;
4
5 /**
6  * Converts typed data objects to arrays.
7  */
8 class TypedDataNormalizer extends NormalizerBase {
9
10   /**
11    * The interface or class that this Normalizer supports.
12    *
13    * @var string
14    */
15   protected $supportedInterfaceOrClass = 'Drupal\Core\TypedData\TypedDataInterface';
16
17   /**
18    * {@inheritdoc}
19    */
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;
26     }
27     return $value;
28   }
29
30 }