/**
  * @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 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();
 }