X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fserialization%2Fsrc%2FNormalizer%2FComplexDataNormalizer.php;fp=web%2Fcore%2Fmodules%2Fserialization%2Fsrc%2FNormalizer%2FComplexDataNormalizer.php;h=e4fcf52b79ce3dfab813f98a77093f19d754b044;hp=33beb373a136b27331e15a44a18b7c2c19b5873f;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php b/web/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php index 33beb373a..e4fcf52b7 100644 --- a/web/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php +++ b/web/core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php @@ -2,6 +2,9 @@ namespace Drupal\serialization\Normalizer; +use Drupal\Core\TypedData\ComplexDataInterface; +use Drupal\Core\TypedData\TypedDataInternalPropertiesHelper; + /** * Converts the Drupal entity object structures to a normalized array. * @@ -26,6 +29,13 @@ class ComplexDataNormalizer extends NormalizerBase { */ public function normalize($object, $format = NULL, array $context = []) { $attributes = []; + // $object will not always match $supportedInterfaceOrClass. + // @see \Drupal\serialization\Normalizer\EntityNormalizer + // Other normalizers that extend this class may only provide $object that + // implements \Traversable. + if ($object instanceof ComplexDataInterface) { + $object = TypedDataInternalPropertiesHelper::getNonInternalProperties($object); + } /** @var \Drupal\Core\TypedData\TypedDataInterface $property */ foreach ($object as $name => $property) { $attributes[$name] = $this->serializer->normalize($property, $format, $context);