I’m writing a Drupal 8 migration from a non-Drupal site where I need to migrate news articles that have inline images in them, sometimes more than 10. I’ve figured I’ll do this in two steps:
- A migration for creating file entities for each image present in the source node body.
- A migration that creates news article entities, and for each image encountered, look up the file entity that was created in the 1st migration and use the File Usage API to indicate the file is used in this node.
My problem is the first migration. The Migration API wants to map a single source to a single destination. I need to be able to map a single source to MULTIPLE destinations, since I will be creating as many as 10 file entities from this single source row.
Does anyone know if this is possible, and if so, are there any examples in core or contrib migrating like this?
If I can’t find a way to do it this way, I’ll instead just migrate everything in the same single migration, and create the file entities on the fly. I’ll just have to write a custom rollback implementation to remove them as well.
Sponsored by SupremePR