|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace AppBundle\Controller;
|
|
|
|
|
|
+use AppBundle\Entity\Commentaire;
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
@@ -105,4 +106,37 @@ class VideothequeController extends Controller
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Route("/fichefilm/{id}", name="videotheque_voirfilm")
|
|
|
+ */
|
|
|
+ public function voirFilmAction(Request $request, \AppBundle\Entity\Film $film)
|
|
|
+ {
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
+ $repoComment = $em->getRepository('AppBundle:Commentaire');
|
|
|
+ $commentaireUser = $repoComment->findOneBy(array('film'=>$film, 'user'=>$this->getUser()));
|
|
|
+ if (is_null($commentaireUser))
|
|
|
+ {
|
|
|
+ $commentaireUser = new Commentaire();
|
|
|
+ $commentaireUser->setUser($this->getUser());
|
|
|
+ $commentaireUser->setFilm(($film));
|
|
|
+ }
|
|
|
+ $form = $this->createForm('AppBundle\Form\CommentaireType', $commentaireUser);
|
|
|
+ $form->handleRequest($request);
|
|
|
+ if ($form->isSubmitted() && $form->isValid())
|
|
|
+ {
|
|
|
+ $commentaireUser = $form->getData();
|
|
|
+ $em->persist($commentaireUser);
|
|
|
+ $em->flush();
|
|
|
+ $this->addFlash('success', 'Le commentaire a été posté');
|
|
|
+
|
|
|
+ }
|
|
|
+ $commentaires = $repoComment->findBy(array('film'=>$film));
|
|
|
+
|
|
|
+ return $this->render('@App/videotheque/voirfilm.html.twig', array(
|
|
|
+ 'film' => $film,
|
|
|
+ 'commentaires' => $commentaires,
|
|
|
+ 'form' => $form->createView()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
}
|