Skip to content
Snippets Groups Projects

Issue #3327582 by jurgenhaas, tobiasb: Make the delimiter and file extension of csv source plugin overridable

Merged Issue #3327582 by jurgenhaas, tobiasb: Make the delimiter and file extension of csv source plugin overridable
@@ -48,6 +48,9 @@ class EntityImportSourceCSV extends EntityImportSourceLimitIteratorBase implemen
return $instance;
}
protected const DELIMITER = ',';
protected const FILE_EXTENSION = 'csv';
/**
* {@inheritdoc}
*/
@@ -112,7 +115,7 @@ class EntityImportSourceCSV extends EntityImportSourceLimitIteratorBase implemen
'#type' => 'managed_file',
'#title' => $this->t('Upload File'),
'#upload_validators' => [
'file_validate_extensions' => ['csv'],
'file_validate_extensions' => [$this::FILE_EXTENSION],
],
'#required' => $this->isRequired(),
'#multiple' => $this->hasMultiple(),
@@ -334,6 +337,7 @@ class EntityImportSourceCSV extends EntityImportSourceLimitIteratorBase implemen
foreach ($this->getFiles() as $file) {
$csv = Reader::createFromPath($file->getFileUri());
$csv->setHeaderOffset(0);
$csv->setDelimiter($this::DELIMITER);
if ($this->hasCsvEncoding()) {
$filter = "{$this->getCsvFromEncoding()}/{$this->getCsvToEncoding()}";
Loading