|
@@ -84,14 +84,13 @@ class VideothequeController extends AbstractController
|
|
|
/**
|
|
|
* @Route("/modifier/{id}", name="videotheque_modifier")
|
|
|
*/
|
|
|
- public function modifierAction(Request $request, Film $film, UniciteCollections $uniciteCollections, EntityManagerInterface $em)
|
|
|
+ public function modifierAction(Request $request, Film $film, FilmManager $filmManager)
|
|
|
{
|
|
|
$form = $this->createForm(FilmType::class, $film);
|
|
|
$form->handleRequest($request);
|
|
|
if ($form->isSubmitted() && $form->isValid())
|
|
|
{
|
|
|
- $film = $uniciteCollections->assureUniciteCollections($film);
|
|
|
- $em->flush();
|
|
|
+ $filmManager->editFilm($film);
|
|
|
$this->addFlash('success', 'Le film a été modifié');
|
|
|
return $this->redirectToRoute('videotheque_voirfilm',array('id'=>$film->getId()));
|
|
|
}
|
|
@@ -105,19 +104,13 @@ class VideothequeController extends AbstractController
|
|
|
* @Route("/supprimer/{id}", name="videotheque_supprimer")
|
|
|
* @IsGranted("ROLE_ADMIN")
|
|
|
*/
|
|
|
- public function supprimerAction(Request $request, Film $film, EntityManagerInterface $em)
|
|
|
+ public function supprimerAction(Request $request, Film $film, FilmManager $filmManager)
|
|
|
{
|
|
|
$form = $this->get('form.factory')->create();
|
|
|
$form->handleRequest($request);
|
|
|
if ($form->isSubmitted() && $form->isValid())
|
|
|
{
|
|
|
- $commentaire = $em->getRepository('App:Commentaire')->findOneBy(array('film'=>$film));
|
|
|
- if ($commentaire != null)
|
|
|
- {
|
|
|
- $em->remove($commentaire);
|
|
|
- }
|
|
|
- $em->remove($film);
|
|
|
- $em->flush();
|
|
|
+ $filmManager->delFilm($film);
|
|
|
$this->addFlash('success', 'Le film '.$film->getTitre().' a bien été supprimé.');
|
|
|
return $this->redirectToRoute('videotheque_liste');
|
|
|
}
|