You are here

public function Migration::loadFieldMappings in Migrate 7.2

Load any stored field mappings from the database.

1 call to Migration::loadFieldMappings()
Migration::getStoredFieldMappings in includes/migration.inc

File

includes/migration.inc, line 336
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 loadFieldMappings() {
  $result = db_select('migrate_field_mapping', 'mfm')
    ->fields('mfm', array(
    'destination_field',
    'source_field',
    'options',
  ))
    ->condition('machine_name', $this->machineName)
    ->execute();
  foreach ($result as $row) {
    $field_mapping = unserialize($row->options);
    $field_mapping
      ->setMappingSource(MigrateFieldMapping::MAPPING_SOURCE_DB);
    if (empty($row->destination_field)) {
      $this->storedFieldMappings[] = $field_mapping;
    }
    else {
      $this->storedFieldMappings[$row->destination_field] = $field_mapping;
    }
  }
}