public function CSVFileObject::current in Migrate Source CSV 8.2
Same name and namespace in other branches
- 8 src/CSVFileObject.php \Drupal\migrate_source_csv\CSVFileObject::current()
File
- src/
CSVFileObject.php, line 50
Class
- CSVFileObject
- Defines a CSV file object.
Namespace
Drupal\migrate_source_csvCode
public function current() {
$row = parent::current();
if ($row && !empty($this->columnNames)) {
// Only use columns specified in the defined CSV columns.
$row = array_intersect_key($row, $this->columnNames);
// Set meaningful keys for the columns mentioned in $this->csvColumns.
foreach ($this->columnNames as $key => $value) {
// Copy value to more descriptive key and unset original.
$value = key($value);
$row[$value] = isset($row[$key]) ? $row[$key] : NULL;
unset($row[$key]);
}
}
return $row;
}