You are here

public function Spreadsheet::fields in Migrate Spreadsheet 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/migrate/source/Spreadsheet.php \Drupal\migrate_spreadsheet\Plugin\migrate\source\Spreadsheet::fields()

Returns available fields on the source.

Return value

array Available fields in the source, keys are the field machine names as used in field mappings, values are descriptions.

Overrides MigrateSourceInterface::fields

File

src/Plugin/migrate/source/Spreadsheet.php, line 147

Class

Spreadsheet
Provides a source plugin that migrate from spreadsheet files.

Namespace

Drupal\migrate_spreadsheet\Plugin\migrate\source

Code

public function fields() {

  // No column headers provided in config, read worksheet for header row.
  if (!($columns = $this
    ->getConfiguration()['columns'])) {
    $this
      ->initializeIterator();
    $columns = array_keys($this->spreadsheetIterator
      ->getHeaders());
  }

  // Add $row_index_column if it's been configured.
  if ($row_index_column = $this
    ->getConfiguration()['row_index_column']) {
    $columns[] = $row_index_column;
  }
  return array_combine($columns, $columns);
}