Entity/DocumentRepository.php
changeset 57 186c4121c7b3
parent 42 0e57c730bb18
child 63 774ba82dca59
equal deleted inserted replaced
49:e854d8cb376c 57:186c4121c7b3
   363         
   363         
   364         $res = $query->getResult();
   364         $res = $query->getResult();
   365         
   365         
   366         return $res;
   366         return $res;
   367     }
   367     }
       
   368     
       
   369     /**
       
   370      * Copy the tahg lst from one document instance to another
       
   371      * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $src_doc
       
   372      * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $tgt_doc
       
   373      */
       
   374     public function copyTags($src_doc, $tgt_doc)
       
   375     {
       
   376         //remove the previous tags
       
   377         foreach ($tgt_doc->getTags() as $doctag) {
       
   378             $this->getEntityManager()->remove($doctag);
       
   379         }
       
   380         
       
   381         // add the new ones
       
   382         foreach ($src_doc->getTags() as $doctag) {
       
   383             $new_doctag = clone $doctag;
       
   384             $new_doctag->setDocument($tgt_doc);
       
   385             $this->getEntityManager()->persist($new_doctag);
       
   386         }
       
   387         
       
   388         $tgt_doc->setManualOrder(false);
       
   389         $this->getEntityManager()->persist($tgt_doc);
       
   390     }
   368         
   391         
   369 }
   392 }