X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fserialization%2Fsrc%2FNormalizer%2FEntityNormalizer.php;fp=web%2Fcore%2Fmodules%2Fserialization%2Fsrc%2FNormalizer%2FEntityNormalizer.php;h=4103d1dd7a5038fccc119fd7b644c28e5318e761;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=84baec94be87fbfdb16780ee33f34244ba0e9613;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/serialization/src/Normalizer/EntityNormalizer.php b/web/core/modules/serialization/src/Normalizer/EntityNormalizer.php index 84baec94b..4103d1dd7 100644 --- a/web/core/modules/serialization/src/Normalizer/EntityNormalizer.php +++ b/web/core/modules/serialization/src/Normalizer/EntityNormalizer.php @@ -40,13 +40,20 @@ class EntityNormalizer extends ComplexDataNormalizer implements DenormalizerInte // The bundle property will be required to denormalize a bundleable // fieldable entity. - if ($entity_type_definition->hasKey('bundle') && $entity_type_definition->isSubclassOf(FieldableEntityInterface::class)) { - // Get an array containing the bundle only. This also remove the bundle - // key from the $data array. - $bundle_data = $this->extractBundleData($data, $entity_type_definition); + if ($entity_type_definition->isSubclassOf(FieldableEntityInterface::class)) { + // Extract bundle data to pass into entity creation if the entity type uses + // bundles. + if ($entity_type_definition->hasKey('bundle')) { + // Get an array containing the bundle only. This also remove the bundle + // key from the $data array. + $create_params = $this->extractBundleData($data, $entity_type_definition); + } + else { + $create_params = []; + } // Create the entity from bundle data only, then apply field values after. - $entity = $this->entityManager->getStorage($entity_type_id)->create($bundle_data); + $entity = $this->entityManager->getStorage($entity_type_id)->create($create_params); $this->denormalizeFieldData($data, $entity, $format, $context); }