Pārlūkot izejas kodu

Bug de persist si la bande annonce n'était pas bonne

François 6 gadi atpakaļ
vecāks
revīzija
3a40f0b717

+ 6 - 0
src/AppBundle/Controller/VideothequeController.php

@@ -74,7 +74,13 @@ class VideothequeController extends Controller
                     }
                 }
             }
+
 			$em->persist($film);
+            if ($film->getMediaVideo()->getType() == null) {
+                $media = $film->getMediaVideo();
+                $film->setMediaVideo(null);
+                $em->remove($media);
+            }
 			$em->flush();
 			$this->addFlash('success', 'Le film a été ajouté');
 			return $this->redirectToRoute('videotheque_voirfilm', array('id'=>$film->getId()));

+ 3 - 2
src/AppBundle/Entity/Film.php

@@ -67,6 +67,7 @@ class Film
 
     /**
      * @ORM\OneToOne(targetEntity="AppBundle\Entity\MediaVideo", cascade={"persist","remove"})
+     * @ORM\JoinColumn(nullable=true)
      */
     private $mediaVideo;
 
@@ -97,7 +98,7 @@ class Film
     private $usersWhoSeen;
 
     /**
-     * @return mixed
+     * @return \AppBundle\Entity\MediaVideo $mediaVideo
      */
     public function getMediaVideo()
     {
@@ -107,7 +108,7 @@ class Film
     /**
      * @param mixed $mediaVideo
      */
-    public function setMediaVideo(\AppBundle\Entity\MediaVideo $mediaVideo)
+    public function setMediaVideo(\AppBundle\Entity\MediaVideo $mediaVideo = null)
     {
         $this->mediaVideo = $mediaVideo;
     }