Bastien Sevajol 11 years ago
parent
commit
2e3ef63dab

+ 6 - 0
src/Muzich/CoreBundle/Managers/PlaylistManager.php View File

247
       ->findOneById($element_data['id']);
247
       ->findOneById($element_data['id']);
248
   }
248
   }
249
   
249
   
250
+  public function getElementsObjects(Playlist $playlist)
251
+  {
252
+    return $this->entity_manager->getRepository('MuzichCoreBundle:Element')
253
+      ->findById($playlist->getElementsIds());
254
+  }
255
+  
250
 }
256
 }

+ 10 - 5
src/Muzich/CoreBundle/Propagator/EventElement.php View File

114
       $ur->addPoints($score_action);
114
       $ur->addPoints($score_action);
115
       $element->addPoints($score_action);
115
       $element->addPoints($score_action);
116
       $element->increaseCountFavorited();
116
       $element->increaseCountFavorited();
117
+      $this->getEntityManager()->persist($element);
117
     }
118
     }
118
     
119
     
119
     $uea = new UserEventAction($element->getOwner(), $this->container);
120
     $uea = new UserEventAction($element->getOwner(), $this->container);
120
     $event = $uea->proceed(Event::TYPE_FAV_ADDED_ELEMENT, $element->getId());
121
     $event = $uea->proceed(Event::TYPE_FAV_ADDED_ELEMENT, $element->getId());
121
-    $this->container->get('doctrine')->getEntityManager()->persist($event);
122
+    $this->getEntityManager()->persist($event);
122
   }
123
   }
123
   
124
   
124
   /**
125
   /**
136
       $ur->removePoints($score_action);
137
       $ur->removePoints($score_action);
137
       $element->removePoints($score_action);
138
       $element->removePoints($score_action);
138
       $element->uncreaseCountFavorited();
139
       $element->uncreaseCountFavorited();
140
+      $this->getEntityManager()->persist($element);
139
     }
141
     }
140
   }
142
   }
141
   
143
   
176
     ;
178
     ;
177
   }
179
   }
178
   
180
   
179
-  public function removedFromPlaylist(Element $element, User $removed_by_user, Playlist $playlist)
181
+  public function removedFromPlaylist(Element $element, User $removed_by_user, Playlist $playlist, $persist_before = true)
180
   {
182
   {
181
-    // On persiste les modifs pour compter correctement
182
-    $this->getEntityManager()->persist($playlist);
183
-    $this->getEntityManager()->flush();
183
+    if ($persist_before)
184
+    {
185
+      // On persiste les modifs pour compter correctement
186
+      $this->getEntityManager()->persist($playlist);
187
+      $this->getEntityManager()->flush();
188
+    }
184
     
189
     
185
     $ur = new UserReputation($element->getOwner());
190
     $ur = new UserReputation($element->getOwner());
186
     $security_context = new SecurityContext($removed_by_user);
191
     $security_context = new SecurityContext($removed_by_user);

+ 4 - 4
src/Muzich/PlaylistBundle/Controller/EditController.php View File

32
     if (!$this->tokenIsCorrect() || !($playlist = $playlist_manager->findOwnedPlaylistWithId($playlist_id, $this->getUser())))
32
     if (!$this->tokenIsCorrect() || !($playlist = $playlist_manager->findOwnedPlaylistWithId($playlist_id, $this->getUser())))
33
       return $this->jsonNotFoundResponse();
33
       return $this->jsonNotFoundResponse();
34
     
34
     
35
-    $element = $playlist_manager->getElementWithIndex($index);
35
+    $element = $playlist_manager->getElementWithIndex($playlist, $index);
36
     $playlist_manager->removePlaylistElementWithIndex($playlist, $index);
36
     $playlist_manager->removePlaylistElementWithIndex($playlist, $index);
37
     
37
     
38
     $event = new EventElement($this->container);
38
     $event = new EventElement($this->container);
56
     $playlist_manager->addElementToPlaylist($element, $playlist);
56
     $playlist_manager->addElementToPlaylist($element, $playlist);
57
     
57
     
58
     $event = new EventElement($this->container);
58
     $event = new EventElement($this->container);
59
-    $event->addedFromPlaylist($element, $this->getUser(), $playlist);
59
+    $event->addedToPlaylist($element, $this->getUser(), $playlist);
60
     
60
     
61
     $this->persist($element);
61
     $this->persist($element);
62
     $this->flush();
62
     $this->flush();
78
       $this->getPlaylistManager()->addElementToPlaylist($element, $form->getData());
78
       $this->getPlaylistManager()->addElementToPlaylist($element, $form->getData());
79
       
79
       
80
       $event = new EventElement($this->container);
80
       $event = new EventElement($this->container);
81
-      $event->addedFromPlaylist($element, $this->getUser(), $form->getData());
81
+      $event->addedToPlaylist($element, $this->getUser(), $form->getData());
82
 
82
 
83
       $this->persist($element);
83
       $this->persist($element);
84
       $this->flush();
84
       $this->flush();
109
     $this->getPlaylistManager()->removePickedPlaylistToUser($this->getUser(), $playlist);
109
     $this->getPlaylistManager()->removePickedPlaylistToUser($this->getUser(), $playlist);
110
     
110
     
111
     $event = new EventElement($this->container);
111
     $event = new EventElement($this->container);
112
-    $event->addedFromPlaylist($element, $this->getUser(), $new_playlist);
112
+    $event->addedToPlaylist($element, $this->getUser(), $new_playlist);
113
     
113
     
114
     $this->persist($element);
114
     $this->persist($element);
115
     $this->flush();
115
     $this->flush();