public function SpreadsheetIterator::current in Migrate Spreadsheet 8
Same name and namespace in other branches
- 2.0.x src/SpreadsheetIterator.php \Drupal\migrate_spreadsheet\SpreadsheetIterator::current()
File
- src/SpreadsheetIterator.php, line 84
Class
- SpreadsheetIterator
- Provides a spreadsheet iterator.
Namespace
Drupal\migrate_spreadsheet
Code
public function current() {
$keys = $this
->getKeys();
$all_columns = $keys + $this
->getColumns();
if ($row_index_column = $this
->getRowIndexColumn()) {
$all_columns[$row_index_column] = '@';
}
elseif (empty($keys)) {
throw new \InvalidArgumentException("Row index should act as key but no name has been provided. Pass a string in \$config['row_index_column'] key when setting the configuration in SpreadsheetIterator::setConfiguration(\$config), to provide a name for this column.");
}
asort($all_columns);
return array_map(function ($col_letter) {
if ($col_letter === '@') {
return $this
->getAbsoluteRowIndex();
}
elseif ($cell = $this
->getWorksheet()
->getCell("{$col_letter}{$this->getAbsoluteRowIndex()}", FALSE)) {
return $cell
->getCalculatedValue();
}
return NULL;
}, $all_columns);
}