Commit d41ee7de authored by Jonathan Hunt's avatar Jonathan Hunt

#8 Map to migrate Pitches when migrating a Route.

parent c00083fd
......@@ -41,6 +41,14 @@ class ClimbNZRouteMigration extends DrupalNode6Migration {
$this->addFieldMapping('field_ascent', 'field_ascent');
$this->addFieldMapping('field_attribution', 'field_attribution');
$this->addFieldMapping('field_pitches', 'field_pitch')
->sourceMigration('Pitch');
}
public function getPitchByTitle($title) {
$result = db_query("SELECT nid FROM {node} WHERE title=:title", array(':title' => $title))->fetchField();
return $result;
}
public function prepareRow($row) {
......@@ -50,5 +58,12 @@ class ClimbNZRouteMigration extends DrupalNode6Migration {
return FALSE;
}
// Map to child pitches via compound key of route nid and pitch field delta.
// A callback for field_pitches is too late, due to migrate sourceMigration magic.
if (count($row->field_pitch)) {
foreach ($row->field_pitch as $key => $bogus) {
$row->field_pitch[$key] = array('nid' => $row->nid, 'delta' => $key);
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment