public function CSVFileObject::current in Migrate Source CSV 8
Same name and namespace in other branches
- 8.2 src/CSVFileObject.php \Drupal\migrate_source_csv\CSVFileObject::current()
File
- src/
CSVFileObject.php, line 56 - Contains \Drupal\migrate_source_csv\CSVFileObject.php.
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;
}