function Flatten::transform
Same name in other branches
- 9 core/modules/migrate/src/Plugin/migrate/process/Flatten.php \Drupal\migrate\Plugin\migrate\process\Flatten::transform()
- 8.9.x core/modules/migrate/src/Plugin/migrate/process/Flatten.php \Drupal\migrate\Plugin\migrate\process\Flatten::transform()
- 10 core/modules/migrate/src/Plugin/migrate/process/Flatten.php \Drupal\migrate\Plugin\migrate\process\Flatten::transform()
Flatten nested array values to single array values.
For example, [[1, 2, [3, 4]]] becomes [1, 2, 3, 4].
Overrides ProcessPluginBase::transform
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ Flatten.php, line 52
Class
- Flatten
- Flattens the source value.
Namespace
Drupal\migrate\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!is_array($value) && !is_object($value)) {
$type = gettype($value);
throw new MigrateException(sprintf("Input should be an array or an object, instead it was of type '%s'", $type));
}
return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($value)), FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.