Exemplo n.º 1
0
 /**
  * @Route("/login",name="login")
  */
 public function loginAction(Request $request)
 {
     $player = new Player();
     $form = $this->createForm(new LoginType(), $player, array('action' => '', 'method' => 'POST'));
     if ($form->handleRequest($request)->isValid()) {
         $repo = $this->getDoctrine()->getRepository("RollRollBundle:Player");
         $user = $repo->findOneBy(array('pseudo' => $player->getPseudo(), 'password' => $player->getPassword()));
         if ($user) {
             parent::saveUser($player);
             return $this->redirect($this->generateUrl('home'));
         } else {
             return $this->render('RollRollBundle:Default:error.html.twig', array('titre' => "Erreur Login", 'message' => "Erreur"));
         }
     }
     return parent::renderPage('RollRollBundle:User:login.html.twig', array('Login' => $form->createView(), 'title' => 'Connexion'));
 }
Exemplo n.º 2
0
 /**
  * @Route("/createGame", name="createGame")
  */
 public function createGameAction(Request $request)
 {
     $user = parent::getUser();
     if (!$user) {
         return $this->render('RollRollBundle:Default:error.html.twig', array('titre' => "Utilisateur inconnu", 'message' => "Vous devez être connecté pour accéder à cette page"));
     }
     $game = new Game();
     $game->setStatus(0);
     $game->setPlayerOrder($user->getId() . '');
     $grid = new Grid();
     $grid->setScoreSheet('..');
     $grid->setPlayed(0);
     $grid->setOwner($user);
     $grid->setGame($game);
     $form = $this->createForm(new CreateGameType(), $game, array('action' => '', 'method' => 'POST'));
     if ($form->handleRequest($request)->isValid()) {
         $this->getDoctrine()->getManager()->persist($game);
         $this->getDoctrine()->getManager()->persist($grid);
         $this->getDoctrine()->getManager()->flush();
         return $this->render('RollRollBundle:Default:error.html.twig', array('titre' => "Partie créée", 'message' => "Partie " . $game->getName() . " créée"));
     }
     return parent::renderPage('RollRollBundle:User:createGame.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 3
0
 /**
  * @Route("/", name="home")
  */
 public function indexAction()
 {
     return parent::renderPage('RollRollBundle:Default:plateau.html.twig');
 }