This plugin transforms a simple indexed array of values into an array of single-element associative arrays. It allows you to specify a key for each new associative array, making it useful for data manipulation tasks where subsequent plugins require associative structures.
This plugin converts an indexed array of flat values to an indexed array of single-element associative arrays.
That is, each flat value of the original array becomes a new associative array, whose key is defined in the plugin configuration and whose value is the original array's value of that position.
See the example below.
Possible use case: If you have to migrate a multivalue field and pipe it to another process plugin that cannot handle multiple values, you'll need to somehow iterate through the array of values and pipe each one of them to that plugin.
The sub_process plugin that is provided by core can only work on an array of associative arrays. So if your source is something like:
some_source: Array
(
[0] => "one"
[1] => "two"
)then you cannot use sub_process.
This plugin will convert this array to an associative one, with a key that you define in its configuration:
field_my_field:
plugin: make_array_associative
key: my_temp_key
source: some_sourceThen your value will be converted to:
some_source: Array
(
[0] => ["my_temp_key" => "one"]
[1] => ["my_temp_key" => "two"]
)which means that you can now pipe it to the sub_process plugin:
field_my_field:
- plugin: make_array_associative
key: my_temp_key
source: some_source
- plugin: sub_process
process:
final_key:
plugin: some_plugin_that_cannot_handle_multiple_values
source: my_temp_key
Ask your assistant about Migrate process: Make array associative
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.