public function MigrateListCSV::__construct in Migrate 7.2
Constructor for MigrateListCSV.
Parameters
$list_path: The path to the CSV file that holds the list of IDs.
$id_column: The column in the file that holds the IDs. A numeric index for the column, from 0.
$options = array(): An array of further options for the CSV file.
Overrides MigrateList::__construct
File
- plugins/
sources/ csv.inc, line 68 - 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 __construct($list_path, $id_column, $options = array()) {
parent::__construct();
$this->file = $list_path;
$this->idColumn = $id_column;
$this->options = $options;
// fgetcsv specific options
foreach (array(
'length' => NULL,
'delimiter' => ',',
'enclosure' => '"',
'escape' => '\\',
) as $key => $default) {
$this->fgetcsv[$key] = isset($options[$key]) ? $options[$key] : $default;
}
if (!empty($options['header_rows'])) {
$this->headerRows = $options['header_rows'];
}
else {
$this->headerRows = 0;
}
if (!is_numeric($id_column)) {
//we need to store the headers.
$this->csvHandle = fopen($this->file, 'r');
if (!$this
->validResource()) {
return;
}
$this->headers = $this
->getNextLine();
fclose($this->csvHandle);
$this->csvHandle = NULL;
}
}