diff -r 11fd79666374 -r 8551d844b4f3 Entity/DocumentRepository.php --- a/Entity/DocumentRepository.php Fri Nov 04 15:59:49 2011 +0100 +++ b/Entity/DocumentRepository.php Sun Nov 06 23:44:37 2011 +0100 @@ -185,17 +185,26 @@ } } + function getTagsStr($document) + { + $em = $this->getEntityManager(); + $query = $em->createQuery("SELECT t.label FROM WikiTagBundle:DocumentTag dt JOIN dt.tag t WHERE dt.document = :docid"); + $query = $query->setParameter("docid", $document); + $result = $query->getScalarResult(); + $tagstr = array(); + foreach ($result as $res) { + $tagstr[] = $res['label']; + } + return $tagstr; + } + function updateTagsStr($document) { - $tags_str = array(); - foreach($document->getTags() as $tag) - { - $tags_str[] = $tag->getTag()->getLabel(); - } + + $tagstr = $this->getTagsStr($document); - $document->setTagsStr(implode(",",$tags_str)); - - $this->getEntityManager()->flush(); + $document->setTagsStr(implode(",",$tagstr)); + $this->getEntityManager()->persist($document); } } \ No newline at end of file