Created
November 1, 2011 12:04
-
-
Save mkempe/1330391 to your computer and use it in GitHub Desktop.
Copy function to clone an existing object in Extbase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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