senK
senK

Reputation: 2802

Symfony2 how to copy one object value to other

I have two doctrine objects, where one is the temporary object i need to move all the values to the original object

$orgObject = $em->getRepository('Acme:demo')->get($id);
$tempObjec = new demo();

How can i copy one value to other, this is just scenario i am saying

Upvotes: 1

Views: 95

Answers (1)

Gnucki
Gnucki

Reputation: 5133

Try:

$tempObjec = clone $orgObject;

If you have linked object you may define the method __clone of your class:

public function __clone()
{
    // ...
}

Upvotes: 4

Related Questions