You are here

public function WebformSubmissions::__construct in Migrate Webform 7

General initialization of a Migration object.

Overrides Migration::__construct

File

./submissions.inc, line 4

Class

WebformSubmissions

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $simple_fields = array(
    'sid',
    'submitted',
    'remote_addr',
    'is_draft',
  );
  $complex_fields = array(
    'nid',
    'uid',
  );
  $fields = array_merge($simple_fields, $complex_fields);
  $query = $this
    ->query($fields);
  $table_name = 'webform_submissions';
  $this->source = new MigrateSourceSQL($query, $fields, NULL, array(
    'map_joinable' => FALSE,
    'skip_count' => FALSE,
  ));
  $this->destination = new MigrateDestinationTable($table_name);
  $this->map = new MigrateSQLMap($this->machineName, array(
    'sid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Source component ID',
      'alias' => 's',
    ),
  ), MigrateDestinationTable::getKeySchema($table_name));
  $this
    ->addSimpleMappings($simple_fields);
  $this
    ->addFieldMapping('nid', 'nid');
  $this
    ->addFieldMapping('serial', 'sid');

  // Get users if configured
  // Default uid to 1 if we're not mapping it.
  if (variable_get('migrate_webform_user_map_ok', FALSE)) {
    $this
      ->removeFieldMapping('uid');
    $this
      ->addFieldMapping('uid', 'uid')
      ->sourceMigration(variable_get('migrate_webform_user_migration_class', ""))
      ->defaultValue(0);
  }
  else {
    $this
      ->removeFieldMapping('uid');
    $this
      ->addFieldMapping('uid', 'uid')
      ->defaultValue(0);
  }
}