Commit ed35f803 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2933776 by masipila, quietone: Merge handbook documentation to API:...

Issue #2933776 by masipila, quietone: Merge handbook documentation to API: sub_process process plugin
parent eb9b03e3
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
* - key: runs the process pipeline for the key to determine a new dynamic * - key: runs the process pipeline for the key to determine a new dynamic
* name. * name.
* *
* Examples: * Example 1:
* *
* This example demonstrates how migration_lookup process plugin can be applied
* on the following source data.
* @code * @code
* source: Array * source: Array
* ( * (
...@@ -41,10 +43,8 @@ ...@@ -41,10 +43,8 @@
* ) * )
* ... * ...
* @endcode * @endcode
*
* The sub_process process plugin will take these arrays one at a time and run * The sub_process process plugin will take these arrays one at a time and run
* its own process over each one: * its own process for each of them:
*
* @code * @code
* process: * process:
* upload: * upload:
...@@ -58,16 +58,17 @@ ...@@ -58,16 +58,17 @@
* display: list * display: list
* description: description * description: description
* @endcode * @endcode
*
* In this case, each item in the upload array will be processed by the * In this case, each item in the upload array will be processed by the
* sub_process process plugin. The target_id will be found by looking up the * sub_process process plugin. The target_id will be found by looking up the
* destination value from a previous migration. The display and description * destination value from a previous migration using the migration_lookup
* fields will simply be mapped. * process plugin. The display and description fields will be mapped directly.
* *
* In the next example, normally the array returned from sub_process will have * Example 2.
* its original keys. If you need to change the key, it is possible for the
* returned array to be keyed by one of the transformed values in the sub-array.
* *
* Drupal 6 filter formats contain a list of filters belonging to that format
* identified by a numeric delta. A delta of 1 indicates automatic linebreaks,
* delta of 2 indicates the URL filter and so on. This example demonstrates how
* static_map process plugin can be applied on the following source data.
* @code * @code
* source: Array * source: Array
* ( * (
...@@ -91,7 +92,52 @@ ...@@ -91,7 +92,52 @@
* ) * )
* ) * )
* ... * ...
* @endcode
* The sub_process will take these arrays one at a time and run its own process
* for each of them:
* @code
* process:
* filters:
* plugin: sub_process
* source: filters
* process:
* id:
* plugin: static_map
* source:
* - module
* - delta
* map:
* filter:
* 0: filter_html_escape
* 1: filter_autop
* 2: filter_url
* 3: filter_htmlcorrector
* 4: filter_html_escape
* php:
* 0: php_code
* @endcode
* The example above means that we take each array element ([0], [1], etc.) from
* the source filters field and apply the static_map plugin on it. Let's have a
* closer look at the first array at index 0:
* @code
* Array
* (
* [module] => filter
* [delta] => 2
* [weight] => 0
* )
* @endcode
* The static_map process plugin results to value 'filter_url' for this input
* based on the 'module' and 'delta' map.
*
* Example 3.
* *
* Normally the array returned from sub_process will have its original keys. If
* you need to change the key, it is possible for the returned array to be keyed
* by one of the transformed values in the sub-array. For the same source data
* used in the previous example, the migration below would result to keys
* 'filter_2' and 'filter_0'.
* @code
* process: * process:
* filters: * filters:
* plugin: sub_process * plugin: sub_process
...@@ -106,9 +152,8 @@ ...@@ -106,9 +152,8 @@
* delimiter: _ * delimiter: _
* @endcode * @endcode
* *
* In the above example, the keys of the returned array would be filter_2 and * @see \Drupal\migrate\Plugin\migrate\process\MigrationLookup
* filter_0 * @see \Drupal\migrate\Plugin\migrate\process\StaticMap
*
* @see \Drupal\migrate\Plugin\MigrateProcessInterface * @see \Drupal\migrate\Plugin\MigrateProcessInterface
* *
* @MigrateProcessPlugin( * @MigrateProcessPlugin(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment