You are here

public function MigrateListCSV::getIdList in Migrate 7.2

Return an array of IDs from the CSV file.

Return value

array

Overrides MigrateList::getIdList

File

plugins/sources/csv.inc, line 117
Define a MigrateSource for importing from comma separated values files.

Class

MigrateListCSV
Implementation of MigrateList, for retrieving a list of IDs to be migrated from a CSV file.

Code

public function getIdList() {
  $ids = array();
  $this->csvHandle = fopen($this->file, 'r');
  if (!$this
    ->validResource()) {
    return $ids;
  }

  // Skip the headers if any,
  for ($i = 0; $i < $this->headerRows; $i++) {
    $this
      ->getNextLine();
  }
  while ($row = $this
    ->getNextLine()) {
    $ids[] = $row[$this->idColumn];
  }
  fclose($this->csvHandle);
  $this->csvHandle = NULL;
  return $ids;
}