You are here

public function Migration::addFieldMapping in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 includes/migration.inc \Migration::addFieldMapping()

Add a mapping for a destination field, specifying a source field and/or a default value.

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.

16 calls to Migration::addFieldMapping()
BeerCommentMigration::__construct in migrate_example/beer.inc
General initialization of a Migration object.
BeerNodeMigration::__construct in migrate_example/beer.inc
General initialization of a Migration object.
BeerTermMigration::__construct in migrate_example/beer.inc
General initialization of a Migration object.
BeerUserMigration::__construct in migrate_example/beer.inc
General initialization of a Migration object.
MigrateExampleOracle::__construct in migrate_example/migrate_example_oracle/migrate_example_oracle.migrate.inc
General initialization of a Migration object.

... See full list

1 method overrides Migration::addFieldMapping()
XMLMigration::addFieldMapping in plugins/sources/xml.inc
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

File

includes/migration.inc, line 186
Defines the base class for import/rollback processes.

Class

Migration
The base class for all import objects. This is where most of the smarts of the migrate module resides. Migrations are created by deriving from this class, and in the constructor (after calling parent::__construct()) initializing at a minimum the name,…

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 from !source, overridden', array(
      '!name' => $this->machineName,
      '!dest' => $destination_field,
      '!source' => $this->fieldMappings[$destination_field]
        ->getSourceField(),
    )), 'warning');
  }
  $mapping = new MigrateFieldMapping($destination_field, $source_field);
  if (is_null($destination_field)) {
    $this->fieldMappings[] = $mapping;
  }
  else {
    $this->fieldMappings[$destination_field] = $mapping;
  }
  return $mapping;
}