public function SpreadsheetIterator::getKeys in Migrate Spreadsheet 8
Same name and namespace in other branches
- 2.0.x src/SpreadsheetIterator.php \Drupal\migrate_spreadsheet\SpreadsheetIterator::getKeys()
Gets the list of columns that are composing the primary key.
Return value
string[] A list of column names.
Throws
\InvalidArgumentException If a key passed in 'keys' does not exist in the header.
Overrides SpreadsheetIteratorInterface::getKeys
2 calls to SpreadsheetIterator::getKeys()
File
- src/
SpreadsheetIterator.php, line 204
Class
- SpreadsheetIterator
- Provides a spreadsheet iterator.
Namespace
Drupal\migrate_spreadsheetCode
public function getKeys() {
if (!isset($this->cache['keys'])) {
$this->cache['keys'] = [];
if (!empty($this->configuration['keys'])) {
$headers = $this
->getHeaders();
foreach ($this->configuration['keys'] as $key) {
if ($key != $this
->getRowIndexColumn() && !isset($headers[$key])) {
throw new \InvalidArgumentException("Key '{$key}' doesn't exist in the table header.");
}
$this->cache['keys'][$key] = $headers[$key];
}
}
}
return $this->cache['keys'];
}