public function addChallengeAction(request $request)
 {
     // On crée un objet Challenge
     $challenge = new Challenge();
     $challenge->setType('normal');
     $form = $this->get('form.factory')->create(new ChallengeType(), $challenge);
     if ($form->handleRequest($request)->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($challenge);
         $em->flush();
         $request->getSession()->getFlashBag()->add('notice', 'The new challenge has been registered');
         return $this->redirect($this->generateUrl('bf_site_admin_challenges'));
     }
     return $this->render('BFAdminBundle:Admin:addChallenge.html.twig', array('form' => $form->createView()));
 }
 public function addChallengeAction(request $request)
 {
     $user = $this->container->get('security.context')->getToken()->getUser();
     // On crée un objet Challenge
     $challenge = new Challenge();
     $challenge->setType($user->getUsername())->setPartner(0)->setOne('0')->setTwo('0')->setThree('0')->setFour('0')->setFive('0')->setSix('0');
     $form = $this->get('form.factory')->create(new ChallengeAmbassadeurType(), $challenge);
     if ($form->handleRequest($request)->isValid()) {
         $title = $challenge->getTitle();
         $challenge->setTitle($user->getUsername() . ' - ' . $title);
         $em = $this->getDoctrine()->getManager();
         $em->persist($challenge);
         $em->flush();
         $request->getSession()->getFlashBag()->add('notice', 'The new challenge has been registered');
         return $this->redirect($this->generateUrl('bf_ambassadeur_index'));
     }
     return $this->render('BFAmbassadeurBundle:Challenge:add.html.twig', array('form' => $form->createView()));
 }