diff -r e854d8cb376c -r 186c4121c7b3 Entity/DocumentRepository.php --- a/Entity/DocumentRepository.php Mon Nov 28 15:58:34 2011 +0100 +++ b/Entity/DocumentRepository.php Tue Dec 06 14:53:12 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