function Extract::transform
Same name in other branches
- 9 core/modules/migrate/src/Plugin/migrate/process/Extract.php \Drupal\migrate\Plugin\migrate\process\Extract::transform()
- 10 core/modules/migrate/src/Plugin/migrate/process/Extract.php \Drupal\migrate\Plugin\migrate\process\Extract::transform()
- 11.x core/modules/migrate/src/Plugin/migrate/process/Extract.php \Drupal\migrate\Plugin\migrate\process\Extract::transform()
Overrides ProcessPluginBase::transform
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ Extract.php, line 69
Class
- Extract
- Extracts a value from an array.
Namespace
Drupal\migrate\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!is_array($value)) {
throw new MigrateException('Input should be an array.');
}
$new_value = NestedArray::getValue($value, $this->configuration['index'], $key_exists);
if (!$key_exists) {
if (isset($this->configuration['default'])) {
$new_value = $this->configuration['default'];
}
else {
throw new MigrateException('Array index missing, extraction failed.');
}
}
return $new_value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.