public function WineUserUpdatesMigration::prepare in Migrate 7.2
File
- migrate_example/
wine.inc, line 1823 - 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.
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:
$account->field_migrate_example_gender = NULL;
break;
}
}