You are here

public function ImageNodeDrupalMigration::__construct in Image 7

Parameters

array $arguments:

Overrides DrupalMigration::__construct

File

image_migrate/image_migrate.image.inc, line 26
Class for migrating Image module D6 files for image nodes into Drupal 7.

Class

ImageNodeDrupalMigration
Migration for image data on image nodes, migrating to an imagefield on nodes.

Code

public function __construct(array $arguments) {
  parent::__construct($arguments);
  $this->imageNodeMigration = $arguments['image_node_migration'];
  $this->dependencies[] = $this->imageNodeMigration;
  $this->fileMigration = $arguments['file_migration'];
  $this->dependencies[] = $this->fileMigration;
  $this->source = new MigrateSourceSQL($this
    ->query(), $this->sourceFields, NULL, $this->sourceOptions);
  $this->destination = new MigrateDestinationNode($arguments['image_node_type']);

  // Update existing nodes instead of creating new ones.
  $this->systemOfRecord = Migration::DESTINATION;
  $this->map = new MigrateSQLMap($this->machineName, array(
    'nid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Source node ID',
      'alias' => 'n',
    ),
  ), MigrateDestinationNode::getKeySchema());

  // Node id.
  $this
    ->addFieldMapping('nid', 'nid')
    ->sourceMigration($this->imageNodeMigration);

  // Image file id.
  $image_field = $arguments['image_field'];
  $this
    ->addFieldMapping($image_field . ':file_class')
    ->defaultValue('MigrateFileFid');
  $this
    ->addFieldMapping($image_field, 'fid')
    ->sourceMigration($this->fileMigration);
}