|
@@ -52,8 +52,6 @@ class VideothequeController extends Controller
|
|
|
return $this->redirectToRoute('videotheque_liste');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
return $this->render('@App/videotheque/ajouter.html.twig', array(
|
|
|
'form' => $form->createView(),
|
|
|
'film' => $film
|
|
@@ -63,16 +61,14 @@ class VideothequeController extends Controller
|
|
|
|
|
|
* @Route("/modifier/{id}", name="videotheque_modifier")
|
|
|
*/
|
|
|
- public function modifierAction(Request $request, $id)
|
|
|
+ public function modifierAction(Request $request, Film $film)
|
|
|
{
|
|
|
- $em = $this->getDoctrine()->getManager();
|
|
|
- $repo = $em->getRepository('AppBundle:Film');
|
|
|
- $film = $repo->find($id);
|
|
|
$form = $this->createForm(FilmType::class, $film);
|
|
|
$form->handleRequest($request);
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid())
|
|
|
{
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
$film = $form->getData();
|
|
|
$em->flush();
|
|
|
$this->addFlash('success', 'Le film a été modifié');
|
|
@@ -88,18 +84,16 @@ class VideothequeController extends Controller
|
|
|
|
|
|
* @Route("/supprimer/{id}", name="videotheque_supprimer")
|
|
|
*/
|
|
|
- public function supprimerAction($id)
|
|
|
+ public function supprimerAction(Request $request, Film $film)
|
|
|
{
|
|
|
- $em = $this->getDoctrine()->getManager();
|
|
|
- $repo = $em->getRepository('AppBundle:Film');
|
|
|
- $film = $repo->find($id);
|
|
|
-
|
|
|
$form = $this->get('form.factory')->create();
|
|
|
+ $form->handleRequest($request);
|
|
|
if ($form->isSubmitted() && $form->isValid())
|
|
|
{
|
|
|
+ $em = $this->getDoctrine()->getManager();
|
|
|
$em->remove($film);
|
|
|
$em->flush();
|
|
|
- $this->addFlash('success', "Le film \"$film\" a bien été supprimé.");
|
|
|
+ $this->addFlash('success', 'Le film '.$film->getTitre().' a bien été supprimé.');
|
|
|
return $this->redirectToRoute('videotheque_liste');
|
|
|
}
|
|
|
|