symfony - clone doctrine ArrayCollection without reference -


when

$originaltags = $task->gettags(); $task->removetag($tag1); 

then $tag1 removed in $originaltags. assignment of arraycollections made reference, how can clone new arraycollection?

you can use native php clone object cloning.

$originaltags = $task->gettags(); $task2 = clone $task; $task2->removetag($tag1); 

Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -