You are here

public function WebformSubmittedData::prepareRow in Migrate Webform 7

Default implementation of prepareRow(). This method is called from the source plugin upon first pulling the raw data from the source.

Parameters

$row: Object containing raw source data.

Return value

bool TRUE to process this row, FALSE to have the source skip it.

Overrides Migration::prepareRow

File

./submitteddata.inc, line 67

Class

WebformSubmittedData

Code

public function prepareRow($row) {

  // skip?
  if (parent::prepareRow($row) === FALSE) {
    return FALSE;
  }
  $row->nid = $this
    ->handleSourceMigration($this->arguments['node_migrations'], $row->nid);

  // find the type of the component we are transferring
  // cannot expand the base query because cid is part of the uniqueness
  $type = db_select('webform_component', 'wc')
    ->fields('wc', array(
    'type',
    'name',
  ))
    ->condition('cid', $row->cid)
    ->condition('nid', $row->nid)
    ->execute()
    ->fetchField();

  // mangle the file ID to be the new version
  if ($type == 'file' || $type == 'private_file') {
    $filemigrations = explode(' ', variable_get('migrate_webform_file_migration_class', ""));
    foreach ($filemigrations as $key => $filemigration) {
      $destfile = db_select('migrate_map_' . strtolower($filemigration), 'map')
        ->fields('map', array(
        'destid1',
      ))
        ->condition('map.sourceid1', $row->data)
        ->execute()
        ->fetchField();
      if ($destfile != NULL) {
        $row->data = $destfile;
        file_usage_add(file_load($destfile), 'webform', 'submission', $row->sid);
      }
    }
  }
}