- Status changed to Needs work
over 1 year ago 9:03pm 5 April 2023 - 🇺🇸United States mglaman WI, USA
We handled this in acquia_dam and needed a bit more work – to handle multiple value metadata in DAM to non-multiple value fields in Drupal
// The field mapping is used by some attributes to transform values for // better storage compatibility. $field_map = $media->bundle->entity->getFieldMap(); $field_definition = NULL; if (isset($field_map[$attribute_name])) { $field_definition = $media->getFieldDefinition($field_map[$attribute_name]); }
We got the field mapping and the field definition.
Then when retrieving the value:
$is_multiple = $field_definition && $field_definition->getFieldStorageDefinition()->isMultiple(); return $is_multiple ? $value : implode(', ', $value);
- Assigned to chakkche
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 4:10am 6 April 2023 - 🇮🇳India chakkche
Rewritten patch according to suggestion from @mglaman in comment #5
- 🇺🇸United States mglaman WI, USA
Thanks @chakkche! I will review and add test coverage
- Assigned to mglaman
- @mglaman opened merge request.
- Issue was unassigned.
- Status changed to Fixed
over 1 year ago 4:09pm 10 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.