You are here

public function WineUserMigration::__construct in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 migrate_example/wine.inc \WineUserMigration::__construct()

General initialization of a Migration object.

Overrides AdvancedExampleMigration::__construct

File

migrate_example/wine.inc, line 217
Advanced migration examples. These serve two purposes:

Class

WineUserMigration

Code

public function __construct() {
  parent::__construct();
  $this->description = t('Wine Drinkers of the world');
  $this->dependencies = array(
    'WinePrep',
    'WineRole',
  );
  $this->map = new MigrateSQLMap($this->machineName, array(
    'accountid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Account ID.',
    ),
  ), MigrateDestinationUser::getKeySchema());
  $query = db_select('migrate_example_wine_account', 'wa')
    ->fields('wa', array(
    'accountid',
    'status',
    'posted',
    'name',
    'password',
    'mail',
    'last_access',
    'last_login',
    'original_mail',
    'sig',
    'sex',
    'positions',
  ));
  $this->source = new MigrateSourceSQL($query);
  $this->destination = new MigrateDestinationUser();

  // Mapped fields
  $this
    ->addSimpleMappings(array(
    'name',
    'status',
    'mail',
  ));
  $this
    ->addFieldMapping('created', 'posted');
  $this
    ->addFieldMapping('access', 'last_access');
  $this
    ->addFieldMapping('login', 'last_login');
  $this
    ->addFieldMapping('pass', 'password');
  $this
    ->addFieldMapping('roles', 'positions')
    ->separator(',')
    ->sourceMigration('WineRole');
  $this
    ->addFieldMapping('signature', 'sig');
  $this
    ->addFieldMapping('signature_format')
    ->defaultValue($this->basicFormat);
  $this
    ->addFieldMapping('init', 'original_mail');

  // Unmapped source fields
  // Unmapped destination fields
  $this
    ->addUnmigratedDestinations(array(
    'theme',
    'timezone',
    'language',
    'picture',
    'role_names',
  ));
}