/** * Migrator constructor. * @param string|array $fileset * @param $logger */ public function __construct($fileset, $logger = null) { // Load configuration file(s) $this->loadConf($fileset); if (array_key_exists('source', $this->conf)) { // Set sources if it does not exist if (!array_key_exists('sources', $this->conf)) { $this->conf['sources'] = array(); } // Move single source into sources list $this->conf['sources'][] = $this->conf['source']; } // Create configuration object $this->conf = new Configuration($this->conf); // Init workflow parent::__construct($this->createTask(), $logger); $this->addWriter($this->createWriter()); // Starting line and number of items to get $this->addFilter(new OffsetFilter($this->conf->get(array('options', 'offset'), 0), $this->conf->get(array('options', 'count'), null))); // Add processors to the workflow $processor = $this->conf->get(array('processors'), array()); if (is_array($processor) && !empty($processor)) { $this->addItemConverter(new Processor($processor)); } // Add mapping to the workflow $mapping = $this->conf->get(array('mapping'), array()); if (is_array($mapping) && !empty($mapping)) { $this->addItemConverter(new Mapping($mapping)); } }