You are here

public function XMLMigration::addFieldMapping in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 plugins/sources/xml.inc \XMLMigration::addFieldMapping()

Override the default addFieldMapping(), so we can create our special field mapping class. TODO: Find a cleaner way to just substitute a different mapping class

Parameters

string $destinationField: Name of the destination field.

string $sourceField: Name of the source field (optional).

boolean $warn_on_override: Set to FALSE to prevent warnings when there's an existing mapping for this destination field.

Overrides Migration::addFieldMapping

File

plugins/sources/xml.inc, line 227
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->fieldMappings[$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->fieldMappings[] = $mapping;
  }
  else {
    $this->fieldMappings[$destination_field] = $mapping;
  }
  return $mapping;
}