VideothequePersonnelleController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. class VideothequePersonnelleController extends AbstractController
  8. {
  9. /**
  10. * @Route("/maliste/", name="videothequepersonnelle_maliste")
  11. */
  12. public function maListeAction (Request $request)
  13. {
  14. $films = $this
  15. ->getDoctrine()
  16. ->getManager()
  17. ->getRepository('App:Film')
  18. ->findTousFavoritesByUser($this->getUser());
  19. return $this->render('videotheque/liste.html.twig', array(
  20. 'listeFilms' => $films,
  21. 'titre' => 'Ma liste de films à voir'
  22. ));
  23. }
  24. /*public function maListeAction (Request $request)
  25. {
  26. $resultats = array();
  27. $user = $this->getUser();
  28. foreach ($user->getFilms() as $key => $film) {
  29. $resultats[$key] = $this->get('serializer')->serialize($film, 'json');
  30. }
  31. return new JsonResponse($resultats);
  32. }*/
  33. /**
  34. * @Route("/maliste/modifieravoir/", name="maliste_modifier_a_voir")
  35. * @param Request $request
  36. * @return JsonResponse
  37. */
  38. public function modifierFilmDansListeAction(Request $request)
  39. {
  40. $em = $this->getDoctrine()->getManager();
  41. $repo = $em->getRepository('App:Film');
  42. $film = $repo->find($request->request->get('id_film'));
  43. if ($request->isXmlHttpRequest())
  44. {
  45. $film->inverseUserWantToView($this->getUser());
  46. $em->flush();
  47. }
  48. /*$resultat = $this->get('serializer')->serialize($film, 'json');*/
  49. return new JsonResponse('OK');
  50. }
  51. /**
  52. * @Route("/maliste/modifiervus/", name="maliste_modifier_vus")
  53. * @param Request $request
  54. * @return JsonResponse
  55. */
  56. public function modifierFilmVusAction(Request $request)
  57. {
  58. $em = $this->getDoctrine()->getManager();
  59. $repo = $em->getRepository('App:Film');
  60. $film = $repo->find($request->request->get('id_film'));
  61. if ($request->isXmlHttpRequest())
  62. {
  63. $film->inverseUserWhoSeen($this->getUser());
  64. $em->flush();
  65. }
  66. /*$resultat = $this->get('serializer')->serialize($film, 'json');*/
  67. return new JsonResponse('OK');
  68. }
  69. }