Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Migrate process: Make array associative

No security coverage Under active development 43 sites

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_source

Then 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
Drupal 10–11

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.

Activity

Tracked releases
2
Tracked since
Sep 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.4 Stable 10–11 Oct 28, 2024
1.0.3 Stable 8–10 Sep 18, 2023