diff -r 80a400379dd3 -r ea562f37d7a5 Entity/DocumentRepository.php --- a/Entity/DocumentRepository.php Thu Dec 08 18:43:14 2011 +0100 +++ b/Entity/DocumentRepository.php Fri Dec 09 02:21:17 2011 +0100 @@ -365,5 +365,28 @@ return $res; } + + /** + * Copy the tahg lst from one document instance to another + * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $src_doc + * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $tgt_doc + */ + public function copyTags($src_doc, $tgt_doc) + { + //remove the previous tags + foreach ($tgt_doc->getTags() as $doctag) { + $this->getEntityManager()->remove($doctag); + } + + // add the new ones + foreach ($src_doc->getTags() as $doctag) { + $new_doctag = clone $doctag; + $new_doctag->setDocument($tgt_doc); + $this->getEntityManager()->persist($new_doctag); + } + + $tgt_doc->setManualOrder(false); + $this->getEntityManager()->persist($tgt_doc); + } } \ No newline at end of file