diff --git a/Seance5-6/seance/index.php b/Seance5-6/seance/index.php index a035d740d613ea7479dea5fb7f5b8d497f84314c..c4bd7c13a84a07c2f38eaf4e9dece66806b7d72e 100644 --- a/Seance5-6/seance/index.php +++ b/Seance5-6/seance/index.php @@ -25,6 +25,10 @@ $app->get('/api/games/',function() { IndexController::partie2(); })->name('partie2'); +$app->get('/partie4',function(){ + IndexController::partie4($id); +})->name('partie4'); + $app->run(); diff --git a/Seance5-6/seance/src/controller/IndexController.php b/Seance5-6/seance/src/controller/IndexController.php index 728087ec218361c9a7f27a8a407e7f034ce75fa3..4505ac949d8c3c5aad68c6b6928f45eca75533ed 100644 --- a/Seance5-6/seance/src/controller/IndexController.php +++ b/Seance5-6/seance/src/controller/IndexController.php @@ -44,4 +44,11 @@ class IndexController $cq2->render(); } + public static function partie4($id){ + $game = Game::find($id); + + $vue = new VuePartie4($game); + $vue->render(); + } + } \ No newline at end of file diff --git a/Seance5-6/seance/src/view/VuePartie1.php b/Seance5-6/seance/src/view/VuePartie1.php index 1967e6bfa8a59ee76ec4dfc163a88e296a331faf..1a7f1ad9ec76a1afceaeff963447d5e804c08571 100644 --- a/Seance5-6/seance/src/view/VuePartie1.php +++ b/Seance5-6/seance/src/view/VuePartie1.php @@ -12,21 +12,21 @@ class VuePartie1 $json = json_encode($game); $this->content = <<< END -<!DOCTYPE html> -<html lang="fr"> -<head> - <meta charset="UTF-8" content="application/json"> - - <link rel="stylesheet" href="css/main.css"> - - <title>photobox</title> -</head> + <!DOCTYPE html> + <html lang="fr"> + <head> + <meta charset="UTF-8" content="application/json"> + + <link rel="stylesheet" href="css/main.css"> + + <title>photobox</title> + </head> -<body> + <body> -$json + $json -</body> + </body> END; diff --git a/Seance5-6/seance/src/view/VuePartie4.php b/Seance5-6/seance/src/view/VuePartie4.php new file mode 100644 index 0000000000000000000000000000000000000000..59a74e9adfa5755fc040bf14ae6e6dfec9f7cdd7 --- /dev/null +++ b/Seance5-6/seance/src/view/VuePartie4.php @@ -0,0 +1,42 @@ +<?php + +namespace seance\view; +class VuePartie4 +{ + + private $content; + + public function __construct($game) + { + $game->description = "..."; + $json = json_encode($game); + $json = $json . '"links" : { + "self" : { "href" : "/api/games/'.$game->id.'"}'; + + $this->content = <<< END + <!DOCTYPE html> + <html lang="fr"> + <head> + <meta charset="UTF-8" content="application/json"> + + <link rel="stylesheet" href="css/main.css"> + + <title>photobox</title> + </head> + + <body> + + $json + + </body> + +END; + + } + + public function render() + { + echo $this->content; + } + +} \ No newline at end of file