You are here

public function WebformSettings::__construct in Migrate Webform 7

General initialization of a Migration object.

Overrides Migration::__construct

File

./settings.inc, line 5

Class

WebformSettings

Code

public function __construct(array $arguments) {
  parent::__construct($arguments);
  $simple_fields = array(
    'confirmation',
    'redirect_url',
    'status',
    'block',
    'teaser',
    'allow_draft',
    'auto_save',
    'submit_notice',
    'submit_text',
    'submit_limit',
    'submit_interval',
    'total_submit_limit',
    'total_submit_interval',
  );
  $complex_fields = array(
    'nid',
    'confirmation_format',
  );
  $fields = array_merge($simple_fields, $complex_fields);
  $query = $this
    ->query($fields);
  $table_name = 'webform';
  $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',
    ),
  ), MigrateDestinationTable::getKeySchema($table_name));
  $this
    ->addSimpleMappings($simple_fields);
  $this
    ->addFieldMapping('nid', 'nid');
  $this
    ->addFieldMapping('confirmation_format', 'confirmation_format')
    ->callbacks(array(
    $this,
    'mapFormat',
  ));
  if (db_field_exists($table_name, 'preview_message')) {
    $this
      ->addFieldMapping('preview_message')
      ->defaultValue('');
  }
  if (db_field_exists($table_name, 'preview_message_format')) {
    $this
      ->addFieldMapping('preview_message_format')
      ->defaultValue($arguments['default_format']);
  }
  if (db_field_exists($table_name, 'preview_excluded_components')) {
    $this
      ->addFieldMapping('preview_excluded_components')
      ->defaultValue('');
  }
}