data-import
data-import copied to clipboard
[DoctrineWriter] Return entity after writeItem() method call
#271
This PR add the return of the entity after calling the writeItem()
method on DoctrineWriter
.
Whats the usecase of this? I can't merge this PR without any good reason.
Ah nevermind, i don't see the linked issue :see_no_evil:
I think you don't use the workflow in the right way. What you want is to persist an collection, this should be handled in the writer itself.
Sorry, I don't figure out how to manage it in your way :s
To be more specific on my use case: I'm calling an API which return a tree and his nodes and I want to import it on my own database.
Each nodes (and for the fun, with inheritance) have a tree
and a parentNode
properties.
I would like to be able to flush
all my entities at the same time (I have event subscribers at the insertion of a new tree and a new node).
Thanks for your time
Interesting use case :+1:
I would say you should use a item converter which converts your api response to an object (for example your entity). This converter should convert your tree node, too.
Register the DoctrineWriter and let them persist each node. You don't have to care about persist the relationip. Doctrine will do it for you.
One hint: If you import a large dataset, don't use doctrine at all, use raw SQL. Doctrine will consume a huge memory.