public function MigrateExampleDateMigration::prepareRow in Migrate Extras 6.2
Default implementation of prepareRow(). This method is called from the source plugin upon first pulling the raw data from the source.
Parameters
$row: Object containing raw source data.
Return value
bool TRUE to process this row, FALSE to have the source skip it.
Overrides Migration::prepareRow
File
- migrate_extras_examples/
migrate_extras_date/ migrate_extras_date.migrate.inc, line 93 - Examples and test fodder for migration into date fields.
Class
- MigrateExampleDateMigration
- Migration class to test import of various date fields.
Code
public function prepareRow($current_row) {
// An advanced feature of the date field handler is that in addition to the
// basic (from) date itself, we can add additional properties like timezone,
// encapsulating them as JSON.
// The date range field can have multiple values
$current_row->date_range_from = array();
foreach ($current_row->xml->date_range as $range) {
$date_data = array(
'from' => (string) $range->from[0],
'to' => (string) $range->to[0],
);
$current_row->date_range_from[] = drupal_to_js($date_data);
}
$date_data = array(
'from' => (string) $current_row->xml->datestamp_range->from[0],
'to' => (string) $current_row->xml->datestamp_range->to[0],
);
$current_row->datestamp_range_from = drupal_to_js($date_data);
$date_data = array(
'from' => (string) $current_row->xml->datetime_range->from[0],
'to' => (string) $current_row->xml->datetime_range->to[0],
'timezone' => (string) $current_row->xml->datetime_range->timezone[0],
);
$current_row->datetime_range_from = drupal_to_js($date_data);
$date_data = array(
'from' => (string) $current_row->xml->date_repeat->date[0],
'rrule' => (string) $current_row->xml->date_repeat->rule[0],
);
$current_row->date_repeat = drupal_to_js($date_data);
}