You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kai Möller edited this page Jan 13, 2020
·
3 revisions
Thoughts
do not set DataProvider and ImportResult within constructor of importer
An importer instance gets its DataProvider via parameter of import method
When import method is called the first thing do do is creating ImportResult.
Implement ImporterInterface
interface ImporterInterface
{
public function import(DataProviderInterface $dataProvider);
}
Implement a DataProviderFactory wich creates and configures the DataProvider. The validation of parameters for the DataProvider i.e. file encoding for csv files could be done here.
To run an import the steps would be
create an instance of the DataProviderFactory
create an instance of the Importer
use the DataProviderFactory for creating the DataProvider
run the import method of the Importer with the created DataProvider as parameter
When using EntityImport start a transaction before doing anything such as deleting rows in beforeProcessRows()