Skip to content
Snippets Groups Projects

Allow /dev/null as the path configuration

All threads resolved!
Files
2
@@ -12,7 +12,8 @@ use League\Csv\Reader;
@@ -12,7 +12,8 @@ use League\Csv\Reader;
* Source for CSV files.
* Source for CSV files.
*
*
* Available configuration options:
* Available configuration options:
* - path: Path to the CSV file. File streams are supported.
* - path: Path to the CSV file. File streams are supported. Use /dev/null to
 
* get an empty source (useful for migration_lookup).
* - ids: Array of column names that uniquely identify each record. Column
* - ids: Array of column names that uniquely identify each record. Column
* names used as IDs can only contain letters (uppercase and lowercase),
* names used as IDs can only contain letters (uppercase and lowercase),
* numbers (0-9), and underscores. No spaces or other special characters
* numbers (0-9), and underscores. No spaces or other special characters
@@ -103,6 +104,12 @@ class CSV extends SourcePluginBase implements ConfigurableInterface {
@@ -103,6 +104,12 @@ class CSV extends SourcePluginBase implements ConfigurableInterface {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
$this->setConfiguration($configuration);
$this->setConfiguration($configuration);
 
// Replace /dev/null with an empty regular file.
 
if ($this->configuration['path'] === '/dev/null') {
 
$this->configuration['path'] = __DIR__ . '/empty.csv';
 
$this->configuration['header_offset'] = NULL;
 
}
 
// Path is required.
// Path is required.
if (empty($this->configuration['path'])) {
if (empty($this->configuration['path'])) {
throw new \InvalidArgumentException('You must declare the "path" to the source CSV file in your source settings.');
throw new \InvalidArgumentException('You must declare the "path" to the source CSV file in your source settings.');
Loading