diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php index 14f4d26..c740c81 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php @@ -37,8 +37,10 @@ public function normalize($object, $format = null, array $context = array()) { // pass in the referenced entity with a flag that ensures it is rendered as // a node reference and not a node definition. $entity_wrapper = new JsonldEntityWrapper($object->entity, $format, $this->serializer, $this->siteSchemaManager); + $properties = $entity_wrapper->getProperties(); return array( '@id' => $entity_wrapper->getId(), + 'uuid' => $properties['uuid'], ); } diff --git a/core/modules/serialization/lib/Drupal/serialization/Plugin/serialization/entityreference_handler/Uuid.php b/core/modules/serialization/lib/Drupal/serialization/Plugin/serialization/entityreference_handler/Uuid.php new file mode 100644 index 0000000..34b43f1 --- /dev/null +++ b/core/modules/serialization/lib/Drupal/serialization/Plugin/serialization/entityreference_handler/Uuid.php @@ -0,0 +1,42 @@ +getSetting('uuid_key'); + $uuid = $data[$uuid_key]; + while (is_array($uuid)) { + $uuid = reset($uuid); + } + + $entity = entity_load_by_uuid($this->getSetting('target_entity_type'), $uuid); + return $entity->id(); + } + +}