public function DrupalNode7Migration::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 DrupalNodeMigration::prepareRow
File
- d7/
node.inc, line 75 - Implementation of DrupalNodeMigration for Drupal 7 sources.
Class
- DrupalNode7Migration
- Handling specific to a Drupal 7 source for nodes.
Code
public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
// The property 'tnid' cannot be handled via sourceMigration() method
// because it might be 0 or the main node of translation set. We don't want
// to create a stub for such cases.
if (!empty($row->tnid)) {
$destination_ids = $this
->getMap()
->lookupDestinationID(array(
$row->tnid,
));
// There's no destination yet. Create a stub.
if (empty($destination_ids)) {
// Don't create stub for itself.
if ($row->tnid != $row->nid) {
// Check if 'tnid' is a node in the source set to prevent not
// updatable stubs.
$query = clone $this
->query();
$query
->condition('n.nid', $row->tnid);
$nid = $query
->execute()
->fetchField();
unset($query);
if ($nid) {
if ($tnids = $this
->createStub(NULL)) {
// Save the mapping.
$this->map
->saveIDMapping((object) array(
'nid' => $row->tnid,
), $tnids, MigrateMap::STATUS_NEEDS_UPDATE, $this->defaultRollbackAction);
$row->tnid = reset($tnids);
}
}
}
else {
$row->tnid = 0;
$row->_is_translation_source = TRUE;
}
}
else {
$row->tnid = $destination_ids['destid1'];
}
}
}