flow-framework

Copy/clone model with relations


A few times now I had to clone a model including its relations. Some relations had to be copied, some had to be ignored and some had to be referenced to the same relation.

e.g. lets say I want to copy an address with contacts and a category, so I want to clone the address and make a copy of all contacts, but make the category relation to the existing category (not copying the category..).

Is there already an easy way (service/utility) I could use?

I found a good service in Extbase (https://github.com/TYPO3-svn-archive/wildside_extbase/blob/master/Classes/Utility/CloningService.php) which is a bit older. If there is no better way, I try to port this to Flow and post the link here..


Solution

  • I ported the given example now to TYPO3 Flow and refactored a bit.

    https://gist.github.com/chvonrohr/f417e7e76b0e0dfb94d4