You are here

public function DrupalFile6Migration::__construct in Drupal-to-Drupal data migration 7.2

Required arguments:

source_connection - Connection key for the DatabaseConnection holding the source Drupal installation. source_version - Major version number (as an integer) of the source install. machine_name - Machine name under which a particular migration is registered. description - Description of the migration. group_name - The group (import job) containing this migration (import task).

Optional arguments:

source_database - Array describing the source connection, to be defined in the constructor. If absent, the source connection is assumed to be established elsewhere (typically settings.php). group - Migration group to add this migration to. dependencies - Array of migrations that must be run before this one. soft_dependencies - Array of migrations that should be listed before this one. format_mappings - Array keyed by source format IDs or machine names, with the values being the corresponding D7 machine name. If unspecified, source_options - Array to be passed as options to source constructors, overriding the defaults (map_joinable FALSE, cache_counts TRUE, cache_key derived from the machine name). version_class - The name of a custom DrupalVersion class overriding the default derived from source_version. new_only - For any destination types that support highwater marks or track_changes, suppress that support so repeated migrations only import new items.

Parameters

array $arguments:

Overrides DrupalFileMigration::__construct

1 call to DrupalFile6Migration::__construct()
DrupalPicture6Migration::__construct in d6/file.inc
Required arguments:
1 method overrides DrupalFile6Migration::__construct()
DrupalPicture6Migration::__construct in d6/file.inc
Required arguments:

File

d6/file.inc, line 10
Implementation of DrupalFileMigration for Drupal 6 sources.

Class

DrupalFile6Migration
@file Implementation of DrupalFileMigration for Drupal 6 sources.

Code

public function __construct(array $arguments) {
  parent::__construct($arguments);
  if (!$this->newOnly) {
    $this->highwaterField = array(
      'name' => 'timestamp',
      'alias' => 'f',
      'type' => 'int',
    );
  }
  $this
    ->addFieldMapping('value', 'filepath');
  $this
    ->addFieldMapping('destination_file', 'filepath')
    ->callbacks(array(
    $this,
    'fixUri',
  ));
  $this
    ->addFieldMapping('timestamp', 'timestamp');
  $this->legacyPath = unserialize(Database::getConnection('default', $this->sourceConnection)
    ->select('variable', 'v')
    ->fields('v', array(
    'value',
  ))
    ->condition('name', 'file_directory_path')
    ->execute()
    ->fetchField());
  if (!$this->legacyPath) {

    // If features are in use, the variable may not be in the variables table,
    // but we might find it strongarmed in cache.
    $strongarm = Database::getConnection('default', $this->sourceConnection)
      ->select('cache', 'c')
      ->fields('c', array(
      'data',
    ))
      ->condition('cid', 'strongarm')
      ->execute()
      ->fetchField();
    if ($strongarm) {
      $strongarm = unserialize($strongarm);
      foreach ($strongarm as $key => $value) {
        if ($key == 'file_directory_path') {
          $this->legacyPath = $value;
          break;
        }
      }
    }
  }
  if (!$this->legacyPath) {
    $this->legacyPath = 'sites/default/files/';
  }

  // Strip ./ from the beginning
  if (substr($this->legacyPath, 0, 2) == './') {
    $this->legacyPath = substr($this->legacyPath, 2);
  }
  $this
    ->addUnmigratedSources(array(
    'status',
  ));
}