|
@@ -11,21 +11,22 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use App\Entity\Film;
|
|
|
-use App\Entity\Genre;
|
|
|
use App\Form\CommentaireType;
|
|
|
use App\Form\FilmType;
|
|
|
+use App\Repository\CommentaireRepository;
|
|
|
+use App\Repository\FilmRepository;
|
|
|
+use App\Repository\GenreRepository;
|
|
|
+use App\Repository\RealisateurRepository;
|
|
|
use App\Service\CommentaireManager;
|
|
|
use App\Service\FilmManager;
|
|
|
-use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
|
class VideothequeController extends AbstractController
|
|
|
{
|
|
|
/**
|
|
|
* @Route("/", name="videotheque_liste")
|
|
|
*/
|
|
|
- public function listeAction(Request $request, EntityManagerInterface $em)
|
|
|
+ public function listeAction(Request $request, FilmRepository $repo)
|
|
|
{
|
|
|
- $repo = $em->getRepository(Film::class);
|
|
|
$listeFilms = $repo->findTous();
|
|
|
|
|
|
return $this->render('videotheque/liste.html.twig', array(
|
|
@@ -37,9 +38,9 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/liste-by/{id}", name="videotheque_listepargenre")
|
|
|
*/
|
|
|
- public function listeParGenreAction(\App\Entity\Genre $genre, EntityManagerInterface $em)
|
|
|
+ public function listeParGenreAction(\App\Entity\Genre $genre, FilmRepository $repo)
|
|
|
{
|
|
|
- $films = $em->getRepository(Film::class)->findFilmWithGenre(array($genre->getName()));
|
|
|
+ $films = $repo->findFilmWithGenre(array($genre->getName()));
|
|
|
|
|
|
return $this->render('videotheque/liste.html.twig', array(
|
|
|
'listeFilms' => $films,
|
|
@@ -50,9 +51,9 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/liste-by_real/{id}", name="videotheque_listeparreal")
|
|
|
*/
|
|
|
- public function listeParRealisateurAction(Realisateur $realisateur, EntityManagerInterface $em)
|
|
|
+ public function listeParRealisateurAction(Realisateur $realisateur, FilmRepository $repo)
|
|
|
{
|
|
|
- $films = $em->getRepository(Film::class)->findFilmWithReal(array($realisateur->getNomComplet()));
|
|
|
+ $films = $repo->findFilmWithReal(array($realisateur->getNomComplet()));
|
|
|
|
|
|
return $this->render('videotheque/liste.html.twig', array(
|
|
|
'listeFilms' => $films,
|
|
@@ -124,11 +125,11 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/fichefilm/{id}", name="videotheque_voirfilm")
|
|
|
*/
|
|
|
- public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, EntityManagerInterface $em)
|
|
|
+ public function voirFilmAction(Request $request, \App\Entity\Film $film, CommentaireManager $cm, Security $security, CommentaireRepository $repo)
|
|
|
{
|
|
|
if ($security->isGranted('IS_AUTHENTICATED_REMEMBERED'))
|
|
|
{
|
|
|
- $commentaireUser = $em->getRepository(Commentaire::class)->findOneBy(array('film'=>$film, 'user'=>$this->getUser()));
|
|
|
+ $commentaireUser = $repo->findOneBy(array('film'=>$film, 'user'=>$this->getUser()));
|
|
|
if (is_null($commentaireUser))
|
|
|
{
|
|
|
$commentaireUser = new Commentaire();
|
|
@@ -154,11 +155,9 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/ajax_req_realisateurs", name="videotheque_ajax_realisateurs")
|
|
|
*/
|
|
|
- public function ajaxRealisateurs(Request $request, EntityManagerInterface $em)
|
|
|
+ public function ajaxRealisateurs(Request $request, RealisateurRepository $repo)
|
|
|
{
|
|
|
- $realisateurs = $em
|
|
|
- ->getRepository(Realisateur::class)
|
|
|
- ->findNomsComplets();
|
|
|
+ $realisateurs = $repo->findNomsComplets();
|
|
|
$liste = array();
|
|
|
foreach ($realisateurs as $key=>$nom)
|
|
|
{
|
|
@@ -171,11 +170,9 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/ajax_req_genres", name="videotheque_ajax_genres")
|
|
|
*/
|
|
|
- public function ajaxGenres(Request $request, EntityManagerInterface $em)
|
|
|
+ public function ajaxGenres(Request $request, GenreRepository $repo)
|
|
|
{
|
|
|
- $genres = $em
|
|
|
- ->getRepository(Genre::class)
|
|
|
- ->findGenres();
|
|
|
+ $genres = $repo->findGenres();
|
|
|
$liste = array();
|
|
|
foreach ($genres as $key=>$nom)
|
|
|
{
|