François Drouhard 5 年之前
父節點
當前提交
a3f7cd65f4
共有 1 個文件被更改,包括 3 次插入5 次删除
  1. 3 5
      src/Controller/VideothequeController.php

+ 3 - 5
src/Controller/VideothequeController.php

@@ -13,6 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
 use App\Entity\Film;
 use App\Form\FilmType;
+use App\Service\FilmManager;
 use Doctrine\ORM\EntityManagerInterface;
 
 class VideothequeController extends AbstractController
@@ -62,18 +63,15 @@ class VideothequeController extends AbstractController
 	/**
 	 * @Route("/ajouter", name="videotheque_ajouter")
 	 */
-	public function ajouterAction(Request $request, UniciteCollections $uniciteCollections, EntityManagerInterface $em)
+	public function ajouterAction(Request $request, UniciteCollections $uniciteCollections, FilmManager $filmManager)
 	{
 		$film = new Film;
-		$film->setAuthered($this->getUser());
 		$form = $this->createForm(FilmType::class, $film);
 
 		$form->handleRequest($request);
 		if ($form->isSubmitted() && $form->isValid())
 		{
-            $film = $uniciteCollections->assureUniciteCollections($film);
-			$em->persist($film);
-			$em->flush();
+			$filmManager->addFilm($film);
 			$this->addFlash('success', 'Le film a été ajouté');
 			return $this->redirectToRoute('videotheque_voirfilm', array('id'=>$film->getId()));
 		}