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()
- 8.9.x 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()
Overrides ProcessPluginBase::transform
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ Extract.php, line 70
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(sprintf("Input should be an array, instead it was of type '%s'", gettype($value)));
}
$new_value = NestedArray::getValue($value, $this->configuration['index'], $key_exists);
if (!$key_exists) {
if (array_key_exists('default', $this->configuration)) {
$new_value = $this->configuration['default'];
}
else {
throw new MigrateException(sprintf("Array index missing, extraction failed for '%s'. Consider adding a `default` key to the configuration.", Variable::export($value)));
}
}
return $new_value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.