You are here

public function WebformSubmittedData::__construct in Migrate Webform 7

General initialization of a Migration object.

Overrides Migration::__construct

File

./submitteddata.inc, line 4

Class

WebformSubmittedData

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $simple_fields = array(
    'no',
    'data',
  );
  $complex_fields = array(
    'nid',
    'sid',
    'cid',
  );
  $fields = array_merge($simple_fields, $complex_fields);
  $query = $this
    ->query($fields);
  $table_name = 'webform_submitted_data';
  $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(
    'nid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Source node ID',
      'alias' => 'n',
    ),
    'sid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Source submission ID',
      'alias' => 's',
    ),
    'cid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Source component ID',
      'alias' => 'c',
    ),
    'no' => array(
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
      'description' => 'Source component instance ID?',
      'alias' => 'o',
    ),
  ), MigrateDestinationTable::getKeySchema($table_name));
  $this
    ->addSimpleMappings($simple_fields);
  $this
    ->addFieldMapping('nid', 'nid');
  $this
    ->addFieldMapping('sid', 'sid')
    ->sourceMigration('WebformSubmissions');
  $this
    ->addFieldMapping('cid', 'cid');

  // @todo consult WebformComponents
  // ... but first see https://drupal.org/node/2093073
}