Sfoglia il codice sorgente

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

bastien 12 anni fa
parent
commit
c9253e3118

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

@@ -310,7 +310,14 @@ class Group
310 310
    */
311 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 322
     // Pour les nouveaux ids restants
316 323
     foreach ($tags as $tag)

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

@@ -117,27 +117,35 @@ class DefaultController extends Controller
117 117
     try {
118 118
       
119 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 123
         ->getSingleResult()
123 124
       ;
124 125
       
125 126
     } catch (\Doctrine\ORM\NoResultException $e) {
126
-        throw $this->createNotFoundException('Groupe introuvable.');
127
+        return $this->createNotFoundException();
127 128
     }
128 129
     
129 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 141
     $group->setTagsToIds();
135 142
     $form = $this->getGroupForm($group);
136 143
     
137 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