Same name and namespace in other branches
- 8.9.x core/modules/migrate/src/Plugin/migrate/process/StaticMap.php \Drupal\migrate\Plugin\migrate\process\StaticMap
- 9 core/modules/migrate/src/Plugin/migrate/process/StaticMap.php \Drupal\migrate\Plugin\migrate\process\StaticMap
Hierarchy
- class \Drupal\migrate\Plugin\migrate\process\StaticMap extends \Drupal\migrate\ProcessPluginBase
Expanded class hierarchy of StaticMap
4 files declare their use of StaticMap
- BlockRegion.php in core/
modules/ block/ src/ Plugin/ migrate/ process/ BlockRegion.php - FieldType.php in core/
modules/ field/ src/ Plugin/ migrate/ process/ FieldType.php - FilterID.php in core/
modules/ filter/ src/ Plugin/ migrate/ process/ FilterID.php - StaticMapTest.php in core/
modules/ migrate/ tests/ src/ Unit/ process/ StaticMapTest.php
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ process/ StaticMap.php, line 148
Namespace
Drupal\migrate\Plugin\migrate\processView source
class StaticMap extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StaticMap:: |
public | function | 3 |