You are here

public function GameBaseball::prepareRow in Migrate 7.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_example_baseball/migrate_example_baseball.migrate.inc, line 116
A baseball game migration example.

Class

GameBaseball
A migration that is reused for each source CSV file.

Code

public function prepareRow($row) {

  // Collect all the batters into one multi-value field.
  for ($i = 1; $i <= 9; $i++) {
    $key = "visiting_batter_{$i}";
    $visiting_batters[] = $row->{$key};
    $key = "home_batter_{$i}";
    $home_batters[] = $row->{$key};
  }
  $row->visiting_batters = implode(',', $visiting_batters);
  $row->home_batters = implode(',', $home_batters);
  $row->title = "{$row->home_team} vs. {$row->visiting_team}. " . gmdate('M d, Y', strtotime($row->start_date));
}