Browse Source

bug fix: Lors de la modification d'un group il arrivais que le tableau de tags oit un stdClass :/

bastien 13 years ago
parent
commit
c9253e3118

+ 8 - 1
src/Muzich/CoreBundle/Entity/Group.php View File

310
    */
310
    */
311
   public function setTagsWithIds(EntityManager $em, $ids)
311
   public function setTagsWithIds(EntityManager $em, $ids)
312
   {
312
   {
313
-    $tags = $em->getRepository('MuzichCoreBundle:Tag')->findByIds($ids)->execute();
313
+    // bug fix: il arrive que ce soit un stdClass qui soit transmis
314
+    $nids = array();
315
+    foreach ($ids as $id)
316
+    {
317
+      $nids[] = $id;
318
+    }
319
+    
320
+    $tags = $em->getRepository('MuzichCoreBundle:Tag')->findByIds($nids)->execute();
314
 
321
 
315
     // Pour les nouveaux ids restants
322
     // Pour les nouveaux ids restants
316
     foreach ($tags as $tag)
323
     foreach ($tags as $tag)

+ 15 - 7
src/Muzich/GroupBundle/Controller/DefaultController.php View File

117
     try {
117
     try {
118
       
118
       
119
       $group = $this->getDoctrine()
119
       $group = $this->getDoctrine()
120
-        ->getRepository('MuzichCoreBundle:Group')
121
-        ->findOneBySlug($slug)
120
+        ->getEntityManager()->createQuery('SELECT g, t FROM MuzichCoreBundle:Group g
121
+        LEFT JOIN g.tags t WHERE g.slug = :gslug')
122
+        ->setParameter('gslug', $slug)
122
         ->getSingleResult()
123
         ->getSingleResult()
123
       ;
124
       ;
124
       
125
       
125
     } catch (\Doctrine\ORM\NoResultException $e) {
126
     } catch (\Doctrine\ORM\NoResultException $e) {
126
-        throw $this->createNotFoundException('Groupe introuvable.');
127
+        return $this->createNotFoundException();
127
     }
128
     }
128
     
129
     
129
     if ($group->getOwner()->getId() != $user->getId())
130
     if ($group->getOwner()->getId() != $user->getId())
130
     {
131
     {
131
-      throw $this->createNotFoundException('Vous n\'ête pas le créateur de ce groupe.');
132
+      return $this->createNotFoundException();
133
+    }
134
+    
135
+    $prompt_tags = array();
136
+    foreach ($group->getTags() as $tag)
137
+    {
138
+      $prompt_tags[$tag->getTag()->getId()] = $tag->getTag()->getName();
132
     }
139
     }
133
     
140
     
134
     $group->setTagsToIds();
141
     $group->setTagsToIds();
135
     $form = $this->getGroupForm($group);
142
     $form = $this->getGroupForm($group);
136
     
143
     
137
     return array(
144
     return array(
138
-      'group'     => $group,
139
-      'form'      => $form->createView()  ,
140
-      'form_name' => 'group'      
145
+      'group'       => $group,
146
+      'form'        => $form->createView(),
147
+      'form_name'   => 'group',
148
+      'search_tags' => $prompt_tags
141
     );
149
     );
142
   }
150
   }
143
   
151