data-import icon indicating copy to clipboard operation
data-import copied to clipboard

[DoctrineWriter] Return entity after writeItem() method call

Open fsevestre opened this issue 9 years ago • 4 comments

#271

This PR add the return of the entity after calling the writeItem() method on DoctrineWriter.

fsevestre avatar Oct 01 '15 20:10 fsevestre

Whats the usecase of this? I can't merge this PR without any good reason.

Baachi avatar Oct 07 '15 19:10 Baachi

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.

Baachi avatar Oct 07 '15 19:10 Baachi

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

fsevestre avatar Oct 07 '15 20:10 fsevestre

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.

Baachi avatar Oct 07 '15 20:10 Baachi