public function onSuccess(Film $film, \RNC\UserBundle\Entity\User $user) { /* à modifier */ $film->setUser($user); $rep = $this->em->getRepository('RNCFilmBundle:Status'); $film->setStatus($rep->findOneBy(array('type' => 'waiting'))); $rep = $this->em->getRepository('RNCFilmBundle:Category'); $film->setCategory($rep->findOneBy(array('name' => 'none'))); $this->em->persist($film->getProducer()); $this->em->persist($film->getDirector()); $this->em->persist($film->getCategory()); $this->em->persist($film->getStatus()); $this->em->persist($film->getUser()); $this->em->persist($film); $this->em->flush(); }
/** * @Route("/register", name="rnc_managefilm_register") * @Template() */ public function registerAction() { $em = $this->getDoctrine()->getEntityManager(); $date_end = new \DateTime($this->get('shk_config.retriever')->shkCfValue('registration_date_end')); $date_start = new \DateTime($this->get('shk_config.retriever')->shkCfValue('registration_date_start')); if (new \DateTime() < $date_start || new \DateTime() > $date_end) { $this->get('session')->setFlash('error', 'entries.incorrect'); return $this->redirect($this->generateUrl('rnc_managefilm_index')); } $film = new Film(array('fr' => array('synopsis' => ''), 'en' => array('synopsis' => ''))); $user = $this->get('security.context')->getToken()->getUser(); $rep = $em->getRepository('RNCFilmBundle:Status'); $film->setStatus($rep->findOneBy(array('type' => 'waiting'))); $rep = $em->getRepository('RNCFilmBundle:Category'); $film->setCategory($rep->findOneBy(array('name' => 'none'))); $film->setUser($user); $film->setEdition(intval($this->get('shk_config.retriever')->shkCfValue('festival_edition'))); $form = $this->createForm(new FilmType(), $film); $formHandler = new FilmHandler($form, $this->get('request'), $em); if ($formHandler->process()) { $this->get('session')->setFlash('success', 'form.register.flash_success'); return $this->redirect($this->generateUrl('rnc_managefilm_show', array('id' => $film->getId()))); } return $this->render('RNCFilmBundle:ManageFilm:register.html.twig', array('form' => $form->createView())); }
public function testInit() { $film = new Film(array('fr' => array('synopsis' => 'Voici le synopsis du film'), 'en' => array('synopsis' => 'Here is the film synopsis'))); $datetime = new \DateTime(); $director = new Director(); $producer = new Producer(); $film->setTitle('Un long fleuve tranquille'); $film->setLengthMin(18); $film->setLengthSec(59); $film->setCompletionDate($datetime); $film->setDirector($director); $film->setProducer($producer); $film->setInformations('Some information about the film'); $film->setFirstFilm(false); $film->setColor(true); $film->setFormat('dcp'); $film->setDolbyStereo(true); $this->assertEquals('Voici le synopsis du film', $film->getContent('fr')->getSynopsis()); $this->assertEquals('Here is the film synopsis', $film->getContent('en')->getSynopsis()); $this->assertEquals('Un long fleuve tranquille', $film->getTitle()); $this->assertEquals(18, $film->getLengthMin()); $this->assertEquals(59, $film->getLengthSec()); $this->assertEquals($datetime, $film->getCompletionDate()); $this->assertEquals($director, $film->getDirector()); $this->assertEquals($producer, $film->getProducer()); $this->assertEquals('Some information about the film', $film->getInformations()); $this->assertEquals('dcp', $film->getFormat()); $this->assertTrue($film->isColor()); $this->assertTrue($film->isDolbyStereo()); $this->assertFalse($film->isFirstFilm()); }
public function onSuccess(Film $film) { $film->setNbUpdates($film->getNbUpdates() + 1); $this->em->persist($film); $this->em->flush(); }