/**
  * @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()));
 }
 /**
  *  Update a film 
  *  @Route("/update/{id}", defaults={"id"="0"}, name="rnc_admin_film_update", requirements={"id"="\d+"})
  *  @Template()
  *  @Secure(roles="ROLE_ADMIN") 
  */
 public function updateAction($id)
 {
     $request = $this->get('request');
     if ($request->isXmlHttpRequest()) {
         if ($request->getMethod() == "GET") {
             $id = $request->query->get('id');
         } else {
             if ($request->getMethod() == "POST") {
                 $postData = $request->request->get('rnc_filmbundle_adminfilmtype');
                 $id = $postData['id'];
             }
         }
         $em = $this->getDoctrine()->getEntityManager();
         if (!($film = $em->getRepository('RNC\\FilmBundle\\Entity\\Film')->find($id))) {
             throw new NotFoundHttpException("Film introuvable");
         }
         $form = $this->createForm(new AdminFilmType($film->getId()), $film);
         $formHandler = new FilmHandler($form, $request, $em);
         if ($formHandler->process()) {
             return new Response($film->getCapturePath(), 200);
         }
         return $this->render('RNCAdminBundle:Film:form_update.html.twig', array('form' => $form->createView()));
     } else {
         $em = $this->getDoctrine()->getEntityManager();
         if (!($film = $em->getRepository('RNC\\FilmBundle\\Entity\\Film')->find($id))) {
             throw new NotFoundHttpException("Film introuvable");
         }
         $form = $this->createForm(new AdminFilmType(), $film);
         $formHandler = new FilmHandler($form, $request, $em);
         if ($formHandler->process()) {
             $this->get('session')->setFlash('success', 'Mise à jour réussie !');
             return $this->redirect($this->generateUrl('rnc_admin_film_index'));
         }
         return $this->render('RNCAdminBundle:Film:update.html.twig', array('form' => $form->createView()));
     }
 }