Skip to content

Instantly share code, notes, and snippets.

@mkempe
Created November 1, 2011 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkempe/1330391 to your computer and use it in GitHub Desktop.
Save mkempe/1330391 to your computer and use it in GitHub Desktop.
Copy function to clone an existing object in Extbase.
<?php
// → http://answerpot.com/showthread.php?463705-Cloning%20Model%20and%20add%20to%20repository
public function copyFooAction(Tx_Foo_Domain_Model_Foo $foo) {
$propertyMapper = t3lib_div::makeInstance('Tx_Extbase_Property_Mapper'); // Create new Tx_Extbase_Property_Mapper
$propertyMapper->injectReflectionService(t3lib_div::makeInstance('Tx_Extbase_Reflection_Service'));
$newFoo = new Tx_Foo_Domain_Model_Foo();
$attributes = array('foo',
'bar'
);
$propertyMapper->map($attributes, $foo, $newFoo);
$this->view->assign('foo', $newFoo);
t3lib_div::devLog('Render view...', 'atlas', 0);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment