You are here

public function WineUserMigration::__construct in Migrate 7.2

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

General initialization of a Migration object.

Overrides AdvancedExampleMigration::__construct

File

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

Class

WineUserMigration

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $this->description = t('Wine Drinkers of the world');
  $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',
    'imageid',
    'positions',
  ));
  $this->source = new MigrateSourceSQL($query);
  $this->destination = new MigrateDestinationUser();
  $this->map = new MigrateSQLMap($this->machineName, array(
    'accountid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Account ID.',
    ),
  ), MigrateDestinationUser::getKeySchema());

  // Mapped fields
  $this
    ->addSimpleMappings(array(
    'name',
    'status',
    'mail',
  ));

  // Note that these date/time values are coming in as ISO strings, but
  // Drupal uses UNIX timestamps. The user destination automatically
  // translates them as necessary.
  $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->format);
  $this
    ->addFieldMapping('init', 'original_mail');
  $this
    ->addFieldMapping('field_migrate_example_gender', 'sex')
    ->description(t('Map from M/F to 0/1 in prepare method'));
  $this
    ->addFieldMapping('picture', 'imageid')
    ->sourceMigration('WineFileCopy');

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