[Flow] Copy an object

David Sporer david.sporer at gmail.com
Wed Apr 15 08:45:47 CEST 2015


Hi,

I have a fairly complex model and I want to create a copyAction in my controller that basically duplicates the object.
My first approach was to simply clone the original object with clone().
The problem with this however is that the references to resources and other collections remain the same.
If I clear collections of the copied resource the collection of the original resource is also cleared which I don’t want.
Same thing for resources. Deleting the original object fails because the resource is referenced by the new object also.

Do you have any best practices for doing such a thing?
One approach that I guess would work is creating the copied object from scratch and also manually duplicating all connected objects but that wouldn’t be that easy and I guess there must be an easier way.

Thanks,
David


More information about the Flow mailing list