- π¨πSwitzerland luksak
This works like a charm! Thank you!
I think that for the specific use case of having an array with values this is the simpler and better solution than the approach of β¨ Add wrapper process plugin to wrap/unwrap values in arrays Needs review .
- Status changed to Needs review
about 1 year ago 10:54am 5 January 2024 - π¨πSwitzerland luksak
Sorry, probably that needs a better review ;)
- πΊπΈUnited States benjifisher Boston area
I think you can get the same effect using the
build_array
process plugin from β¨ Process plugin to build an array Active .Instead of this example from the doc block for
iterate
process: field_dates: plugin: iterate source: field_timestamps process: plugin: format_date from_format: 'U' to_format: 'Y-m-d\TH:i:s'
you can use
build_array
to prepare the array of arrays thatsub_process
expects:process: field_dates: - plugin: build_array source: field_timestamps template: - 'pipeline:' - plugin: sub_process process: plugin: format_date from_format: 'U' to_format: 'Y-m-d\TH:i:s' source: '0'
As @danflanagan8 pointed out in #3, it is much simpler in this case to let the Migrate API loop through the array for you, but I think this example shows that any time you want to use
iterate
, you can get the same effect withbuild_array
andsub_process
.Many simple uses of
sub_process
can also be handled bybuild_array
. The second example from #3 becomesfield_node_references: - plugin: explode delimiter: '/' source: field_links - plugin: build_array template: - pipeline:2 - plugin: migration_lookup migration: node
The
build_array
plugin usesarray_walk_recursive()
, which is a lot simpler thansub_process
anditerate
, both of which create a separate process pipeline. So I prefer to usebuild_array
when it can replace one of the others.