Exemplo n.º 1
0
 public function addAction($categoryId, Request $request)
 {
     $playlist = new Playlist();
     $em = $this->getDoctrine()->getManager();
     if ($categoryId == null) {
         $category = $em->getRepository('LCVPlaylistBundle:PlaylistCategory')->findOneByName('Default');
     } else {
         $category = $em->getRepository('LCVPlaylistBundle:PlaylistCategory')->findOneById($categoryId);
     }
     $playlist->setCategory($category);
     $form = $this->createForm(new PlaylistType(), $playlist);
     if ($form->handleRequest($request)->isValid()) {
         $playlist->setAuthor($this->getUser());
         $playlist->setRate(new Rating());
         $em->persist($playlist);
         $em->flush();
         $request->getSession()->getFlashBag()->add('success', 'Playlist bien enregistrée !');
         return $this->redirect($this->generateUrl('lcv_playlist_edit', array('playlist_id' => $playlist->getId())));
     }
     return $this->render('LCVPlaylistBundle:Playlist:add.html.twig', array('playlist' => $playlist, 'form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * Add playlists
  *
  * @param \LCV\PlaylistBundle\Entity\Playlist $playlists
  * @return User
  */
 public function addPlaylist(\LCV\PlaylistBundle\Entity\Playlist $playlists)
 {
     $this->playlists[] = $playlists;
     $playlists->setAuthor($this);
     return $this;
 }