You are here

public function DateExampleMigration::prepareRow in Date 7.3

Same name and namespace in other branches
  1. 8 date_migrate/date_migrate_example/date_migrate_example.migrate.inc \DateExampleMigration::prepareRow()
  2. 7.2 tests/date_migrate_test/date_migrate_test.migrate.inc \DateExampleMigration::prepareRow()

Transforms the raw migration data into the expected date formats.

An advanced feature of the date field handler is that in addition to the basic (Start) date itself, we can add additional properties like timezone, encapsulating them as JSON.

Overrides Migration::prepareRow

File

tests/date_migrate_test/date_migrate_test.migrate.inc, line 107
Examples and test folder for migration into date fields.

Class

DateExampleMigration
Migration class to test import of various date fields.

Code

public function prepareRow($current_row) {

  // The date range field can have multiple values.
  $current_row->date_range_from = array();
  foreach ($current_row->xml->date_range as $range) {
    $current_row->date_range_from[] = (string) $range->from[0];
    $current_row->date_range_to[] = (string) $range->to[0];
  }
  $current_row->datestamp_range_from = (string) $current_row->xml->datestamp_range->from[0];
  $current_row->datestamp_range_to = (string) $current_row->xml->datestamp_range->to[0];
  $current_row->datetime_range_from = (string) $current_row->xml->datetime_range->from[0];
  $current_row->datetime_range_to = (string) $current_row->xml->datetime_range->to[0];
  $current_row->datetime_range_timezone = (string) $current_row->xml->datetime_range->timezone[0];
  $current_row->date_repeat = (string) $current_row->xml->date_repeat->date[0];
  $current_row->date_repeat_rrule = (string) $current_row->xml->date_repeat->rule[0];
}