3 namespace Drupal\migrate\Plugin\migrate\process;
5 use Drupal\migrate\ProcessPluginBase;
6 use Drupal\migrate\MigrateExecutableInterface;
7 use Drupal\migrate\Row;
10 * This plugin iterates and processes an array.
12 * @link https://www.drupal.org/node/2135345 Online handbook documentation for iterator process plugin @endlink
14 * @MigrateProcessPlugin(
16 * handle_multiples = TRUE
19 class Iterator extends ProcessPluginBase {
22 * Runs a process pipeline on each destination property per list item.
24 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
26 if (!is_null($value)) {
27 foreach ($value as $key => $new_value) {
28 $new_row = new Row($new_value, []);
29 $migrate_executable->processRow($new_row, $this->configuration['process']);
30 $destination = $new_row->getDestination();
31 if (array_key_exists('key', $this->configuration)) {
32 $key = $this->transformKey($key, $migrate_executable, $new_row);
34 $return[$key] = $destination;
41 * Runs the process pipeline for the current key.
43 * @param string|int $key
45 * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
46 * The migrate executable helper class.
47 * @param \Drupal\migrate\Row $row
48 * The current row after processing.
51 * The transformed key.
53 protected function transformKey($key, MigrateExecutableInterface $migrate_executable, Row $row) {
54 $process = ['key' => $this->configuration['key']];
55 $migrate_executable->processRow($row, $process, $key);
56 return $row->getDestinationProperty('key');
62 public function multiple() {