equal
deleted
inserted
replaced
98 $class = $this->getContainer()->getParameter("wiki_tag.document_class"); |
98 $class = $this->getContainer()->getParameter("wiki_tag.document_class"); |
99 |
99 |
100 if(! is_a($doc,"\IRI\Bundle\WikiTagBundle\Model\DocumentInterface")) { |
100 if(! is_a($doc,"\IRI\Bundle\WikiTagBundle\Model\DocumentInterface")) { |
101 $doc_rep = $this->getDoctrine()->getRepository('WikiTagBundle:Document'); |
101 $doc_rep = $this->getDoctrine()->getRepository('WikiTagBundle:Document'); |
102 if(is_a($doc, $class)) { |
102 if(is_a($doc, $class)) { |
103 // todo: use reflection to get the id |
103 // Get the document column id, set in the config file. |
104 $doc_id = $doc_rep->reflectionGetField($doc, Container()->getParameter("wiki_tag.document_id_column")); |
104 $doc_id = $doc_rep->reflectionGetField($doc, Container()->getParameter("wiki_tag.document_id_column")); |
105 } |
105 } |
106 else { |
106 else { |
107 $doc_id = $doc; |
107 $doc_id = $doc; |
108 } |
108 } |
160 if(!$created) { |
160 if(!$created) { |
161 $query = $em->createQuery("SELECT COUNT(dt.id) FROM WikiTagBundle:DocumentTag dt WHERE dt.document = :id_doc AND dt.tag = :tag"); |
161 $query = $em->createQuery("SELECT COUNT(dt.id) FROM WikiTagBundle:DocumentTag dt WHERE dt.document = :id_doc AND dt.tag = :tag"); |
162 $query->setParameters(array("id_doc"=>$doc, "tag"=>$tag)); |
162 $query->setParameters(array("id_doc"=>$doc, "tag"=>$tag)); |
163 $nb_tags = $query->getSingleScalarResult(); |
163 $nb_tags = $query->getSingleScalarResult(); |
164 } |
164 } |
165 |
165 |
166 if($created || $nb_tags==0){ |
166 if($created || $nb_tags==0){ |
167 |
167 $max_order = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->getMaxOrder($doc_id); |
168 $max_order = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->getMaxOrder($doc); |
|
169 $new_order = $max_order + 1; |
168 $new_order = $max_order + 1; |
170 $new_DT = new DocumentTag(); |
169 $new_DT = new DocumentTag(); |
171 $new_DT->setDocument($doc); |
170 $new_DT->setDocument($doc); |
172 $new_DT->setTag($tag); |
171 $new_DT->setTag($tag); |
173 $new_DT->setOriginalOrder($new_order); |
172 $new_DT->setOriginalOrder($new_order); |