Commit f277d1dc authored by webchick's avatar webchick
Browse files

Issue #1931976 follow-up by linclark, effulgentsia: Support deserialization...

Issue #1931976 follow-up by linclark, effulgentsia: Support deserialization for hal+json (minor nit fixes).
parent 45c60ea0
......@@ -80,6 +80,7 @@ public function denormalize($data, $class, $format = NULL, array $context = arra
$typed_data_ids = $this->getTypedDataIds($data['_links']['type']);
$entity = entity_create($typed_data_ids['entity_type'], array('langcode' => $langcode, 'type' => $typed_data_ids['bundle']));
// @todo Handle data in _links and _embedded, http://drupal.org/node/1880424
// Get links and remove from data array.
$links = $data['_links'];
unset($data['_links']);
......@@ -101,12 +102,12 @@ public function denormalize($data, $class, $format = NULL, array $context = arra
$field = $entity->get($field_name);
// Get the class of the field. This will generally be the default Field
// class.
$class = get_class($field);
$field_class = get_class($field);
// Pass in the empty field object as a target instance. Since the context
// is already prepared for the field, any data added to it is
// automatically added to the entity.
$context['target_instance'] = $field;
$this->serializer->denormalize($field_data, $class, $format, $context);
$this->serializer->denormalize($field_data, $field_class, $format, $context);
}
return $entity;
......
......@@ -58,7 +58,7 @@ public function denormalize($data, $class, $format = NULL, array $context = arra
$langcode = $data['lang'];
unset($data['lang']);
$field_definition = $field_item->getDefinition();
if ($field_definition['translatable'] == TRUE) {
if ($field_definition['translatable']) {
$field_item = $this->createTranslatedInstance($field_item, $langcode);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment