Entity/DocumentRepository.php
changeset 23 b435f8055cb4
parent 18 6f16b9fd6a17
child 27 8551d844b4f3
--- a/Entity/DocumentRepository.php	Fri Oct 28 14:57:11 2011 +0200
+++ b/Entity/DocumentRepository.php	Fri Nov 04 11:56:59 2011 +0100
@@ -136,14 +136,15 @@
     
     function writeDocument($document,  $document_id_column, $fields)
     {
-        # get document from id
+        // get document from id
+         
         $docid = $this->reflectionGetField($document, $document_id_column);
         $baseDocument = $this->findOneByExternalId($docid);
     
         if(is_null($baseDocument))
         {
             $baseDocument = new Document();
-            $baseDocument->setExternalId($docid);
+            $baseDocument->setExternalId($document);
         }
         
         foreach ($fields as $name => $field_def) {
@@ -184,4 +185,17 @@
         }
     }
     
+    function updateTagsStr($document)
+    {
+        $tags_str = array();
+        foreach($document->getTags() as $tag)
+        {
+            $tags_str[] = $tag->getTag()->getLabel();
+        }
+        
+        $document->setTagsStr(implode(",",$tags_str));
+        
+        $this->getEntityManager()->flush();
+    }
+        
 }
\ No newline at end of file