Commit cd8452aa authored by runa's avatar runa

added copydeep function

parent 0929be64
...@@ -1196,6 +1196,27 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1196,6 +1196,27 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
return $ret; return $ret;
} }
/**
* copyDeep
* returns a copy of this object and all its related objects
*
* @return Doctrine_Record
*/
public function copyDeep(){
$newObject = $this->copy();
foreach( $this->getTable()->getRelations() as $relation ) {
if ( $relation->getType() == Doctrine_Relation::MANY_COMPOSITE ||
$relation->getType() == Doctrine_Relation::ONE_COMPOSITE ) {
$alias = $relation->getAlias();
foreach ( $this->$alias as $relatedObject ) {
$newRelatedObject = $relatedObject->copyDeep();
$newObject->{$alias}[] = $newRelatedObject;
}
}
}
return $newObject;
}
/** /**
* assignIdentifier * assignIdentifier
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment