public function WineUserMigration::prepare in Migrate 7.2
File
- migrate_example/
wine.inc, line 413 - Advanced migration examples. These serve two purposes:
Class
Code
public function prepare(stdClass $account, stdClass $row) {
// Gender data comes in as M/F, needs to be saved as Male=0/Female=1
// TIP: Note that the Migration prepare method is called after all other
// prepare handlers. Most notably, the field handlers have had their way
// and created field arrays, so we have to save in the same format. In this
// case, best practice would be to use a callback instead (see below), we're
// just demonstrating here what the $account object looks like at this
// stage.
switch ($row->sex) {
case 'm':
case 'M':
$account->field_migrate_example_gender[LANGUAGE_NONE][0]['value'] = 0;
break;
case 'f':
case 'F':
$account->field_migrate_example_gender[LANGUAGE_NONE][0]['value'] = 1;
break;
default:
unset($account->field_migrate_example_gender);
break;
}
}