public function load(ObjectManager $manager)
 {
     $acousticPL = new Playlist();
     $acousticPL->setTitle('Acoustic');
     $manager->persist($acousticPL);
     $resPL = new Playlist();
     $resPL->setTitle('Rock en Seine 2011');
     $manager->persist($resPL);
     $fooFigthers = new Artist();
     $fooFigthers->setName('Foo Figthers');
     $fooFigthers->setGenre('alternative rock');
     $fooFigthers->setType(Artist::TYPE_BAND);
     $fooFigthers->setPicture('http://rockmetalmag.fr/wp-content/uploads/2014/05/foo_fighters_52847.jpg');
     $manager->persist($fooFigthers);
     $track = new Track();
     $track->setTitle('Everlong');
     $track->setArtist($fooFigthers);
     $track->setDuration(287);
     $manager->persist($track);
     $resPL->addTrack($track);
     $track = new Track();
     $track->setTitle('Best of You');
     $track->setArtist($fooFigthers);
     $track->setDuration(308);
     $manager->persist($track);
     $resPL->addTrack($track);
     $track = new Track();
     $track->setTitle('Everlong - Acoustic version');
     $track->setArtist($fooFigthers);
     $track->setDuration(308);
     $manager->persist($track);
     $acousticPL->addTrack($track);
     $arcticMonkeys = new Artist();
     $arcticMonkeys->setName('Arctic Monkeys');
     $arcticMonkeys->setGenre('indie rock');
     $arcticMonkeys->setType(Artist::TYPE_BAND);
     $arcticMonkeys->setPicture('http://www.lesinrocks.com/wp-content/thumbnails/uploads/2014/02/amonk-tt-width-604-height-380-lazyload-0-crop-0-bgcolor-000000.jpg');
     $manager->persist($arcticMonkeys);
     $track = new Track();
     $track->setTitle('Mardy Bum');
     $track->setArtist($arcticMonkeys);
     $track->setDuration(256);
     $manager->persist($track);
     $resPL->addTrack($track);
     $track = new Track();
     $track->setTitle('When the sun goes down');
     $track->setArtist($arcticMonkeys);
     $track->setDuration(320);
     $manager->persist($track);
     $redHot = new Artist();
     $redHot->setName('Red Hot Chili Peppers');
     $redHot->setGenre('californian rock');
     $redHot->setType(Artist::TYPE_BAND);
     $redHot->setPicture(' http://www.sensationrock.net/wp-content/uploads/2015/10/Red-Hot-Chili-Peppers_11506.jpg');
     $manager->persist($redHot);
     $manager->flush();
 }
Пример #2
0
 /**
  * @Route("/show/{uniqID}/{page}.{_format}", name="oktothek_show_playlist", requirements={"page": "\d+"}, defaults={"page": 1, "_format": "html"})
  * @ ParamConverter("playlist", class="MediaBundle:Playlist", options={"mapping": {"playlist": "uniqID"}})
  * @Template()
  */
 public function showAction(Playlist $playlist, $page)
 {
     return ['playlist' => $playlist];
     $em = $this->getDoctrine()->getManager();
     $dql = "SELECT i FROM MediaBundle:Playlistitems i JOIN i.episode WHERE i.playlist = :playlist";
     $query = $em->createQuery($dql);
     $query->setParameter('playlist', $playlist->getId());
     $paginator = $this->get('knp_paginator');
     $items = $paginator->paginate($query, $page, 10);
     return ['playlist' => $playlist, 'items' => $items];
 }
Пример #3
0
 /**
  * creates a new playlist for user and adds episode
  */
 public function newPlaylist($name, $user, $uniqID)
 {
     $playlist = new Playlist();
     $playlist->setUser($user);
     $playlist->setName($name);
     $episode = $this->em->getRepository('AppBundle:Episode')->findOneBy(['uniqID' => $uniqID]);
     $playlistItem = new PlaylistItem();
     $playlistItem->setEpisode($episode);
     $playlist->addItem($playlistItem);
     $this->em->persist($playlist);
     $this->em->persist($playlistItem);
     $this->em->flush();
 }
Пример #4
0
 public function playlistDuration(Playlist $playlist)
 {
     return $this->durationCalculator->calculate($playlist->getId());
 }
 /**
  * @ParamConverter("playlist", class="AppBundle:Playlist", options={"repository_method" = "withTracks"})
  * @Cache(public=true, smaxage="86400")
  */
 public function tracksListAction(Playlist $playlist)
 {
     return $this->render('playlists/tracks-list.html.twig', ['playlistId' => $playlist->getId(), 'tracks' => $playlist->getTracks()]);
 }
Пример #6
0
 /**
  * @Route("/channel/playlist/{uniqID}/edit", name="oktothek_channel_playlist_edit")
  * @Template()
  */
 public function editPlaylistAction(Request $request, Playlist $playlist)
 {
     $this->denyAccessUnlessGranted('edit_channel', $playlist->getSeries());
     $form = $this->createForm(PlaylistUserType::class, $playlist);
     $form->add('submit', SubmitType::class, ['label' => 'oktothek.playlist_update_button', 'attr' => ['class' => 'btn btn-primary']]);
     $form->add('delete', SubmitType::class, ['label' => 'oktothek.playlist_delete_button', 'attr' => ['class' => 'btn btn-link']]);
     if ($request->getMethod() == "POST") {
         //sends form
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             if ($form->get('submit')->isClicked()) {
                 // update post
                 $em->persist($playlist);
                 $em->flush();
                 $this->get('session')->getFlashBag()->add('success', 'oktothek.success_edit_playlist');
                 return $this->redirect($this->generateUrl('oktothek_channel_playlists', ['uniqID' => $playlist->getSeries()->getUniqID()]));
             } else {
                 // delete playlist
                 $em->remove($playlist);
                 $em->flush();
                 $this->get('session')->getFlashBag()->add('success', 'oktothek.success_delete_playlist');
                 return $this->redirect($this->generateUrl('oktothek_channel_playlists', ['uniqID' => $playlist->getSeries()->getUniqID()]));
             }
         } else {
             $this->get('session')->getFlashBag()->add('error', 'oktothek.error_edit_playlist');
         }
     }
     return ['form' => $form->createView(), 'series' => $playlist->getSeries()];
 }