You are here

public function DrupalFile7Migration::prepareRow in Drupal-to-Drupal data migration 7.2

Called after the query data is fetched - we'll use this to populate the source row with the CCK fields.

Overrides Migration::prepareRow

1 call to DrupalFile7Migration::prepareRow()
DrupalYoutube7Migration::prepareRow in d7/file.inc
Called after the query data is fetched - we'll use this to populate the source row with the CCK fields.
1 method overrides DrupalFile7Migration::prepareRow()
DrupalYoutube7Migration::prepareRow in d7/file.inc
Called after the query data is fetched - we'll use this to populate the source row with the CCK fields.

File

d7/file.inc, line 62
Implementation of DrupalFileMigration for Drupal 7 sources.

Class

DrupalFile7Migration
Handling specific to a Drupal 7 source for files.

Code

public function prepareRow($row) {
  if (parent::prepareRow($row) === FALSE) {
    return FALSE;
  }
  $this->version
    ->getSourceValues($row, $row->fid);

  // Do our best to apply the appropriate file_class to the import of this
  // "file". Assume if we don't recognize a special case, we'll treat it as
  // a real file to be copied.
  if ($row->filemime == 'video/youtube' && class_exists('MigrateExtrasFileYoutube')) {
    if (strpos($row->uri, 'youtube://') !== FALSE) {
      $this->destination
        ->setFileClass('MigrateFileUriAsIs');
    }
    else {
      $this->destination
        ->setFileClass('MigrateExtrasFileYoutube');
    }
  }
  elseif (preg_match('|/oembed$|i', $row->filemime)) {
    $this->destination
      ->setFileClass('MigrateFileUriAsIs');
  }
  else {
    $this->destination
      ->setFileClass('MigrateFileUri');

    // Default destination_dir to the incoming stream wrapper.
    if (preg_match('|^([a-z]+://)|i', $row->uri, $matches)) {
      $row->destination_dir = $matches[1];
    }
  }
}