You are here

public function MigrateDestinationNodeRevision::import in Migrate 7.2

Overridden import method.

This is done because parent::import will return the nid of the newly created nodes. This is bad since the migrate_map_* table will have nids instead of vids, which could cause a nightmare explosion on rollback.

Parameters

stdClass $node: Populated entity.

stdClass $row: Source information in object format.

Return value

array|bool Array with newly created vid, or FALSE on error.

Throws

MigrateException

Overrides MigrateDestinationNode::import

File

plugins/destinations/node.inc, line 443
Support for node destinations.

Class

MigrateDestinationNodeRevision
Allows you to import revisions.

Code

public function import(stdClass $node, stdClass $row) {

  // We're importing revisions, this should be set.
  $node->revision = 1;
  if (empty($node->nid)) {
    throw new MigrateException(t('Missing incoming nid.'));
  }
  $original_updated = $this->numUpdated;
  parent::import($node, $row);

  // Reset num updated and increment created since new revision is always an update.
  $this->numUpdated = $original_updated;
  $this->numCreated++;
  if (empty($node->vid)) {
    return FALSE;
  }
  return array(
    $node->vid,
  );
}