コード例 #1
0
ファイル: PronosController.php プロジェクト: Jb-Initio/Pronos
 public function pronostic(Application $app)
 {
     if ($app['session']->get('user') === null) {
         $tmp_message = $app['session']->get('tmp_message');
         if ($tmp_message === null) {
             return $app->redirect("/silex_pronostic/web/index.php/");
         }
     }
     $tab_matches = $app['session']->get('matches');
     $local_name = null;
     $visitor_name = null;
     $local_score_pronos = null;
     $visitor_score_pronos = null;
     $date_debut_match = null;
     $heure_debut_match = null;
     $activate_fields = true;
     $match_id_tmp = $app['session']->get('tmp_message');
     $id_match = $match_id_tmp['match_id'];
     $match = $this->getMatch($tab_matches, $id_match);
     //Données de session
     if ($match != null) {
         $local_name = $match->match_localteam_name;
         $visitor_name = $match->match_visitorteam_name;
         $date_debut_match = $match->match_formatted_date;
         $heure_debut_match = $match->match_time;
     }
     $user = $app['session']->get('user')['user'];
     $nom_user = $user->getNom();
     $db_prono = new DbPronostic();
     $id_user = $db_prono->getIdUser($nom_user);
     if ($id_user != null) {
         //Si l'utilisateur est  enregistré dans la base
         $match = $db_prono->getMatch($id_user, explode("'", $match_id_tmp['match_id'])[1]);
         //Données de bdd
         $local_score_pronos = $match['local_team_score_pronos'];
         $visitor_score_pronos = $match['visitor_team_score_pronos'];
     }
     $activate_fields = $this->isNotTimeout($date_debut_match, $heure_debut_match);
     /*var_dump(array(
           'local_name' =>  $local_name,
           'visitor_name' => $visitor_name,
           'local_pronos' => $local_score_pronos,
           'visitor_pronos' => $visitor_score_pronos,
           'activate_fields' => $activate_fields,
           'heure_debut' => $heure_debut_match,
           'date_debut' => $date_debut_match
       ));*/
     $flash = false;
     return $app['twig']->render('pronostic.twig', array('flash' => $flash, 'local_name' => $local_name, 'visitor_name' => $visitor_name, 'local_pronos' => $local_score_pronos, 'visitor_pronos' => $visitor_score_pronos, 'activate_fields' => $activate_fields, 'heure_debut' => $heure_debut_match, 'date_debut' => $date_debut_match));
 }
コード例 #2
0
ファイル: DbPronosticTest.php プロジェクト: Jb-Initio/Pronos
 public function testGetMatch()
 {
     $expected = array('id' => '2', 'match_id' => '2126781', 'match_date' => '2015-09-21', 'local_team_id' => '6874161', 'local_team_score_pronos' => '684', 'visitor_team_id' => '684', 'visitor_team_score_pronos' => '687', 'point' => null, 'user_id' => '2');
     $dbProno = new DbPronostic();
     $this->assertArraySubset($expected, $dbProno->getMatch('2', '15752'));
 }