equal
deleted
inserted
replaced
134 throw new \Exception("Unknown accessor $accessor"); |
134 throw new \Exception("Unknown accessor $accessor"); |
135 } |
135 } |
136 |
136 |
137 function writeDocument($document, $document_id_column, $fields) |
137 function writeDocument($document, $document_id_column, $fields) |
138 { |
138 { |
139 # get document from id |
139 // get document from id |
|
140 |
140 $docid = $this->reflectionGetField($document, $document_id_column); |
141 $docid = $this->reflectionGetField($document, $document_id_column); |
141 $baseDocument = $this->findOneByExternalId($docid); |
142 $baseDocument = $this->findOneByExternalId($docid); |
142 |
143 |
143 if(is_null($baseDocument)) |
144 if(is_null($baseDocument)) |
144 { |
145 { |
145 $baseDocument = new Document(); |
146 $baseDocument = new Document(); |
146 $baseDocument->setExternalId($docid); |
147 $baseDocument->setExternalId($document); |
147 } |
148 } |
148 |
149 |
149 foreach ($fields as $name => $field_def) { |
150 foreach ($fields as $name => $field_def) { |
150 if(isset($field_def['accessor'])) |
151 if(isset($field_def['accessor'])) |
151 { |
152 { |
182 { |
183 { |
183 $this->getEntityManager()->remove($baseDocument); |
184 $this->getEntityManager()->remove($baseDocument); |
184 } |
185 } |
185 } |
186 } |
186 |
187 |
|
188 function updateTagsStr($document) |
|
189 { |
|
190 $tags_str = array(); |
|
191 foreach($document->getTags() as $tag) |
|
192 { |
|
193 $tags_str[] = $tag->getTag()->getLabel(); |
|
194 } |
|
195 |
|
196 $document->setTagsStr(implode(",",$tags_str)); |
|
197 |
|
198 $this->getEntityManager()->flush(); |
|
199 } |
|
200 |
187 } |
201 } |