public function ImageAttachImageNodeDrupalMigration::__construct in Image 7
Parameters
array $arguments:
Overrides DrupalMigration::__construct
File
- image_migrate/
image_migrate.image_attach.inc, line 30 - Class for migrating Image attach into Drupal 7.
Class
- ImageAttachImageNodeDrupalMigration
- Migration for image attach data into entityreference fields.
Code
public function __construct(array $arguments) {
parent::__construct($arguments);
$this->imageNodeMigration = $arguments['image_node_migration'];
$this->dependencies[] = $this->imageNodeMigration;
$this->attachingNodeMigration = $arguments['attaching_node_migration'];
$this->dependencies[] = $this->attachingNodeMigration;
$this->source = new MigrateSourceSQL($this
->query(), $this->sourceFields, NULL, $this->sourceOptions);
$this->destination = new MigrateDestinationNode($arguments['attaching_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 image attach attaching node ID',
'alias' => 'n',
),
'iid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source image attach image node ID',
'alias' => 'i',
),
), array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source image attach attaching node ID',
'alias' => 'n',
),
'iid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source image attach image node ID',
'alias' => 'i',
),
));
// Attaching node id.
$this
->addFieldMapping('nid', 'nid')
->sourceMigration($this->attachingNodeMigration);
// Image node id.
$attaching_entityreference_field = $arguments['attaching_entityreference_field'];
$this
->addFieldMapping($attaching_entityreference_field, 'iid')
->sourceMigration($this->imageNodeMigration);
}