示例#1
0
 /**
  * @param Playlistitem $entity
  */
 public function preRemove($entity)
 {
     $this->deleteKeyCache('playlistItem_' . $entity->getId());
     $this->playlistQuery->preRemove($entity->getPlaylist());
 }
 /**
  * @Route("/add-to-playlist/{idPlaylist}/{vidId}", requirements={"idPlaylist" = "\d+"}, name="_formAddToPlaylist")
  * @Template()
  */
 public function addtoAction($idPlaylist, $vidId = null)
 {
     $data['title'] = 'Video added';
     $em = $this->getDoctrine()->getManager();
     $playlistQuery = new PlaylistQuery($em);
     $playlistItemQuery = new PlaylistItemQuery($em);
     $playlist = $playlistQuery->setId($idPlaylist)->getSingle('playlist_' . $idPlaylist);
     if ($playlist->getUser()->getId() == $this->getUser()->getId()) {
         $playlistItem = new Playlistitem();
         $playlistItem->setPlaylist($playlist)->setIdVideo($vidId)->getVideoInformation($this->get('youtubeVideo'));
         $playlistItemQuery->persist($playlistItem);
         $result = true;
     } else {
         $result = false;
     }
     $data['content'] = $this->renderView('VidlisCoreBundle:PlaylistActions:addto.html.twig', array('playlistItem' => $playlistItem, 'result' => $result));
     $response = new Response(json_encode($data));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }