function StaticMap::transform
Same name in other branches
- 8.9.x core/modules/migrate/src/Plugin/migrate/process/StaticMap.php \Drupal\migrate\Plugin\migrate\process\StaticMap::transform()
- 10 core/modules/migrate/src/Plugin/migrate/process/StaticMap.php \Drupal\migrate\Plugin\migrate\process\StaticMap::transform()
- 11.x core/modules/migrate/src/Plugin/migrate/process/StaticMap.php \Drupal\migrate\Plugin\migrate\process\StaticMap::transform()
Overrides ProcessPluginBase::transform
3 calls to StaticMap::transform()
- BlockRegion::transform in core/
modules/ block/ src/ Plugin/ migrate/ process/ BlockRegion.php - Performs the associated process.
- FieldType::transform in core/
modules/ field/ src/ Plugin/ migrate/ process/ FieldType.php - Performs the associated process.
- FilterID::transform in core/
modules/ filter/ src/ Plugin/ migrate/ process/ FilterID.php - Performs the associated process.
3 methods override StaticMap::transform()
- BlockRegion::transform in core/
modules/ block/ src/ Plugin/ migrate/ process/ BlockRegion.php - Performs the associated process.
- FieldType::transform in core/
modules/ field/ src/ Plugin/ migrate/ process/ FieldType.php - Performs the associated process.
- FilterID::transform in core/
modules/ filter/ src/ Plugin/ migrate/ process/ FilterID.php - Performs the associated process.
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ StaticMap.php, line 153
Class
- StaticMap
- Changes the source value based on a static lookup map.
Namespace
Drupal\migrate\Plugin\migrate\processCode
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$new_value = $value;
if (is_array($value)) {
if (!$value) {
throw new MigrateException('Can not lookup without a value.');
}
}
else {
$new_value = [
$value,
];
}
$new_value = NestedArray::getValue($this->configuration['map'], $new_value, $key_exists);
if (!$key_exists) {
if (array_key_exists('default_value', $this->configuration)) {
if (!empty($this->configuration['bypass'])) {
throw new MigrateException('Setting both default_value and bypass is invalid.');
}
return $this->configuration['default_value'];
}
if (empty($this->configuration['bypass'])) {
throw new MigrateSkipRowException(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export($value), $destination_property));
}
else {
return $value;
}
}
return $new_value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.