You are here

public function SourceCsvForm::getHeaderColumnNames in Migrate Tools 8.4

Returns the header row.

Use a new file handle so that CSVFileObject::current() is not executed.

Return value

array The header row.

1 call to SourceCsvForm::getHeaderColumnNames()
SourceCsvForm::buildForm in src/Form/SourceCsvForm.php
Form constructor.

File

src/Form/SourceCsvForm.php, line 393

Class

SourceCsvForm
Provides an edit form for CSV source plugin column_names configuration.

Namespace

Drupal\migrate_tools\Form

Code

public function getHeaderColumnNames() {
  $row = [];
  $fname = $this->file
    ->getPathname();
  $handle = fopen($fname, 'r');
  if ($handle) {
    fseek($handle, $this->file
      ->getHeaderRowCount() - 1);
    $row = fgetcsv($handle);
    fclose($handle);
  }
  return $row;
}