-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - success and fail events #17
Comments
Hi Tim, You could do this via the finish event. But you have to figure yourself what "fail" and "success" means. <service id="myimport.endpoint" class="Import\Endpoint\SomeService">
<tag name="kernel.event_listener" event="data-import.finish.myimport" method="finish"/>
</service>
And in SomeService: public function finish(\Mathielen\DataImport\Event\ImportProcessEvent $event)
{
/** @var $import \Mathielen\ImportEngine\Import\Import */
$import = $event->getContext();
$importRun = $import->getRun();
//i.e. - there was at least one row, but none had been successfully written
$hasFailed = $importRun->getStatistics()['processed'] > 0 && $importRun->getStatistics()['written'] === 0;
//do something with the source? - if its a LocalFileStorage...
$sourceStorage = $import->getSourceStorage;
if ($sourceStorage instanceof LocalFileStorage && $hasFailed) {
rename($sourceStorage->getFile(), ...)
}
} Did not test the code above, but you will get the idea. Best regards |
Great! I'll try to implement something like your example. I'm thinking of making a small "example project" where I can combine all questions, would you be interested in something to attach it to your project for documentation? |
That would be awesome! I already thought about it the other day but didnt have the time to really get it started. I'm using the lib in a lot of different projects and could extend the demo with more advanced examples. Would be great to enable more developers to really understand what this library is all about. |
I'm going to give it try when I have the file-upload and validations working. I could provide examples:
And hopefully:
|
Hi Markus,
Another question, where I'm not sure how to handle an automated import process properly.
Situation:
How can I handle the success and fail events?
Is there a event in the ImportEngine to do this? I have seen the "prepare" event but I'm not sure which are the other events and what data they expose.
The text was updated successfully, but these errors were encountered: