Skip to content
Snippets Groups Projects
Commit 5f8a8f41 authored by Jess's avatar Jess
Browse files

Issue #2845479 by Jo Fitzgerald, gerzenstl, quietone, Kifah Meeran, xjm,...

Issue #2845479 by Jo Fitzgerald, gerzenstl, quietone, Kifah Meeran, xjm, phenaproxima: Add documentation to Extract process plugin
parent 4577daf3
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -9,9 +9,52 @@
use Drupal\migrate\Row;
/**
* This plugin extracts a value from an array.
* Extracts a value from an array.
*
* @link https://www.drupal.org/node/2152731 Online handbook documentation for extract process plugin @endlink
* The extract process plugin is used to pull data from an input array, which
* may have multiple levels. One use case is extracting data from field arrays
* in previous versions of Drupal. For instance, in Drupal 7, a field array
* would be indexed first by language, then by delta, then finally a key such as
* 'value'.
*
* Available configuration keys:
* - source: The input value - must be an array.
* - index: The array of keys to access the value.
* - default: (optional) A default value to assign to the destination if the
* key does not exist.
*
* Examples:
*
* @code
* process:
* new_text_field:
* plugin: extract
* source: some_text_field
* index:
* - und
* - 0
* - value
* @endcode
*
* The PHP equivalent of this would be:
* @code
* $destination['new_text_field'] = $source['some_text_field']['und'][0]['value'];
* @endcode
* If a default value is specified, it will be returned if the index does not
* exist in the input array.
*
* @code
* plugin: extract
* source: some_text_field
* default: 'Default title'
* index:
* - title
* @endcode
*
* If $source['some_text_field']['title'] doesn't exist, then the plugin will
* return "Default title".
*
* @see \Drupal\migrate\Plugin\MigrateProcessInterface
*
* @MigrateProcessPlugin(
* id = "extract",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment