コード例 #1
0
 /**
  * @Route("/index", name="view_homepage")
  */
 public function indexAction()
 {
     $quizz = new Quizz();
     $quizz->setTitle("title");
     $quizz->setDescription("description");
     $quizz->setgiftText("giftText");
     $quizz->setgiftImg("favicon.png");
     $quizz->setgiftImg("images/" . $quizz->getGiftImg());
     $user = new Users();
     $user->setNom("Nom");
     $user->setPrenom("Prenom");
     //Classement du user
     $classement = 108;
     //liste des 10 user et le user connecté
     $users = array($user, $user, $user, $user, $user, $user, $user, $user, $user, $user, $user);
     return $this->render('index.html.twig', array('quizz' => $quizz, 'users' => $users, 'classement' => $classement));
 }
コード例 #2
0
 function saveUser($token)
 {
     $repository = $this->em->getRepository('AppBundle:Users');
     $fbUser = $this->getFBUser($token);
     $user = $repository->findOneByIdFacebook($fbUser->getId());
     if (!is_object($user)) {
         $newUser = new Users();
         $newUser->setIdFacebook($fbUser->getId());
         $newUser->setBirthday($fbUser->getField('age_range')['min']);
         $newUser->setEmail($fbUser->getEmail());
         $newUser->setGender($fbUser->getGender());
         $newUser->setNom($fbUser->getLastName());
         $newUser->setPrenom($fbUser->getFirstName());
         $newUser->setToken($token);
         $this->em->persist($newUser);
         $this->em->flush();
     } else {
         $user->setToken($token);
         $this->em->persist($user);
         $this->em->flush();
     }
 }