public function SpreadsheetIterator::getColumns in Migrate Spreadsheet 8
Same name and namespace in other branches
- 2.0.x src/SpreadsheetIterator.php \Drupal\migrate_spreadsheet\SpreadsheetIterator::getColumns()
Gets the list of columns.
Return value
string[] The list of columns.
Throws
\InvalidArgumentException If a column passed in 'columns' does not exist in the header.
Overrides SpreadsheetIteratorInterface::getColumns
See also
\Drupal\migrate_spreadsheet\SpreadsheetIteratorInterface::setColumns()
1 call to SpreadsheetIterator::getColumns()
File
- src/
SpreadsheetIterator.php, line 180
Class
- SpreadsheetIterator
- Provides a spreadsheet iterator.
Namespace
Drupal\migrate_spreadsheetCode
public function getColumns() {
if (!isset($this->cache['columns'])) {
$headers = $this
->getHeaders();
if (empty($this->configuration['columns'])) {
// If no columns were passed, all columns will be used.
$this->cache['columns'] = $headers;
}
else {
$this->cache['columns'] = [];
foreach ($this->configuration['columns'] as $column) {
$column = trim($column);
if (!isset($headers[$column])) {
throw new \InvalidArgumentException("Column '{$column}' doesn't exist in the table header.");
}
$this->cache['columns'][$column] = $headers[$column];
}
}
}
return $this->cache['columns'];
}