public function XMLMigration::addFieldMapping in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/xml.inc \XMLMigration::addFieldMapping()
So we can create our special field mapping class.
@todo Find a cleaner way to just substitute a different mapping class.
Parameters
string|null $destination_field: machine-name of destination field
string|null $source_field: name of source field
bool $warn_on_override: Set to FALSE to prevent warnings when there's an existing mapping for this destination field.
Return value
MigrateXMLFieldMapping MigrateXMLFieldMapping
Overrides Migration::addFieldMapping
File
- plugins/
sources/ xml.inc, line 341 - Support for migration from XML sources.
Class
- XMLMigration
- Migrations using XML sources should extend this class instead of Migration.
Code
public function addFieldMapping($destination_field, $source_field = NULL, $warn_on_override = TRUE) {
// Warn of duplicate mappings.
if ($warn_on_override && !is_null($destination_field) && isset($this->codedFieldMappings[$destination_field])) {
self::displayMessage(t('!name addFieldMapping: !dest was previously mapped, overridden', array(
'!name' => $this->machineName,
'!dest' => $destination_field,
)), 'warning');
}
$mapping = new MigrateXMLFieldMapping($destination_field, $source_field);
if (is_null($destination_field)) {
$this->codedFieldMappings[] = $mapping;
}
else {
$this->codedFieldMappings[$destination_field] = $mapping;
}
return $mapping;
}