equal
deleted
inserted
replaced
404 * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $tgt_doc |
404 * @param IRI\Bundle\WikitagBundle\Model\DocumentInterface $tgt_doc |
405 */ |
405 */ |
406 public function copyTags($src_doc, $tgt_doc) |
406 public function copyTags($src_doc, $tgt_doc) |
407 { |
407 { |
408 //remove the previous tags |
408 //remove the previous tags |
409 foreach ($tgt_doc->getTags() as $doctag) { |
409 if(!is_null($tgt_doc->getTags())) { |
410 $this->getEntityManager()->remove($doctag); |
410 foreach ($tgt_doc->getTags() as $doctag) { |
|
411 $this->getEntityManager()->remove($doctag); |
|
412 } |
411 } |
413 } |
412 |
414 |
413 // add the new ones |
415 // add the new ones |
414 foreach ($src_doc->getTags() as $doctag) { |
416 if(!is_null($src_doc->getTags())) { |
415 $new_doctag = clone $doctag; |
417 foreach ($src_doc->getTags() as $doctag) { |
416 $new_doctag->setDocument($tgt_doc); |
418 $new_doctag = clone $doctag; |
417 $this->getEntityManager()->persist($new_doctag); |
419 $new_doctag->setDocument($tgt_doc); |
|
420 $this->getEntityManager()->persist($new_doctag); |
|
421 } |
418 } |
422 } |
419 |
423 |
420 $tgt_doc->setManualOrder(false); |
424 $tgt_doc->setManualOrder(false); |
421 $this->getEntityManager()->persist($tgt_doc); |
425 $this->getEntityManager()->persist($tgt_doc); |
422 } |
426 } |