Skip to content
Snippets Groups Projects

Allow a callback function for the Source path parameter.

1 file
+ 11
0
Compare changes
  • Side-by-side
  • Inline
@@ -199,6 +199,17 @@ class CSV extends SourcePluginBase implements ConfigurableInterface {
* @throws \League\Csv\Exception
*/
public function initializeIterator() {
// Support a callback to return the path.
if (isset($this->configuration['path']['callback'])) {
if (is_callable($this->configuration['path']['callback'])) {
$this->configuration['path'] = call_user_func($this->configuration['path']['callback']);
}
else {
$message = 'The path callback function is not callable.';
throw new InvalidPluginDefinitionException($this->getPluginId(), $message);
}
}
$header = $this->getReader()->getHeader();
if ($this->configuration['fields']) {
// If there is no header record, we need to flip description and name so
Loading