diff --git a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php index d30b2f5..adfd367 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Iterator.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Iterator.php @@ -7,40 +7,38 @@ use Drupal\migrate\Row; /** - * Iterates and processes an array. + * Iterates and processes an associative array. * - * The iterator process plugin allows processing of a list of associative arrays - * Often source data will include multiple-value properties as associative arrays. - * For example, for filter formats on Drupal 6, the filters property contains a - * list of filters belonging to that format, identified by a numeric delta - * (a delta of 2 indicates the URL filter, a delta of 1 indicates automatic - * breaking, etc.): + * The iterator process plugin allows sub-processing of a list of associative + * arrays. Often source data will include multiple-value properties as + * associative arrays. For example, for file uploads on Drupal 6, the upload + * property contains a list of sub-properties. * * Available configuration keys: * - process: the plugin(s) that will process each element of the source. + * - key: runs the process pipeline for the defined key. * * Examples: * * @code * source: Array * ( - * [format] => 1 - * [name] => Filtered HTML - * ... - * [filters] => Array + * [upload] => Array * ( * [0] => Array * ( - * [module] => filter - * [delta] => 2 - * [weight] => 0 + * [fid] => 1 + * [list] => 0 + * [description] => "File number 1" * ) * [1] => Array * ( - * [module] => filter - * [delta] => 0 - * [weight] => 1 + * [fid] => 2 + * [list] => 1 + * [description] => "File number 2" * ) + * ) + * ) * ... * @endcode * @@ -49,70 +47,40 @@ * * @code * process: - * filters: + * upload: * plugin: iterator - * source: filters + * source: upload * process: - * id: - * plugin: static_map - * source: - * - module - * - delta - * map: - * filter: - * - filter_html_escape - * - filter_autop - * - filter_url - * - filter_htmlcorrector - * - filter_html_escape - * php: - * php_code + * target_id: + * plugin: migration_lookup + * migration: d6_file + * source: fid + * display: list + * description: description * @endcode * - * So, plugin: iterator and source: filters means we take each array - * element in the source filters field, and apply the static_map - * plugin to it. We take the first ([0]) array: + * In this case, each item in the upload array will be processed bye the + * iterator process plugin. The target_id will be found by looking up the + * destination value from a previous migration. The display and description + * fields will simply be mapped. * - * @code - * Array - * ( - * [module] => filter - * [delta] => 2 - * [weight] => 0 - * ) - * @endcode - * - * The map source keys are module and delta, so in the map key, since the - * [module] value is filter, we index the array using the delta value of 2 and - * arrive at filter_url as our value - this will be the first value in the array - * assigned to the destination filters. Similarly, we will take the 0 value for - * the weight in the second array to generate a second value of filter_html_escape. - * - * There's one more problem that needs to be solved: often the key of the arrays - * need to be changed. In this case, the new id property needs to be the key. - * It'd be possible to just add key: "@id" to the iterator process but that - * would require special casing the key property and somehow escape it when - * there is actually a destination called key. Instead, it is moved out of the - * process and key is in the configuration of iterator itself: + * The mapping values passed to iterator are special. Numeric values may not be + * used. * * @code - * process: - * filters: - * plugin: iterator - * source: filters - * key: "@id" - * process: - * id: - * plugin: static_map + * field_relationship: + - + plugin: migration_lookup + * migration: + * - migration_page + * - migration_blog + * source: nid + * - + * plugin: iterator + * process: + * target_id: '0' * @endcode - * - * The process pipeline for key is special in two ways: first, it runs after - * the normal process is done. Because of this, key: "@key" is also valid. - * Second, the pipeline does not start with NULL but the value of the current key. - * This way, the value of key can come from the other properties or the current - * key. For the latter, omit the source from the first plugin in the pipeline - * for key. - * + * In the migration above, the value mapped to target_id is intentionally '0'. * * @see \Drupal\migrate\Plugin\MigrateProcessInterface *