From 5c290c5fa7a9936e443384c344ea5fd073f2b926 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tondon=20C=C3=A9sar?= <pilou.tondon@hotmail.fr>
Date: Wed, 25 Mar 2020 10:32:25 +0100
Subject: [PATCH] partie 4
---
Seance5-6/seance/index.php | 4 ++
.../seance/src/controller/IndexController.php | 7 ++++
Seance5-6/seance/src/view/VuePartie1.php | 24 +++++------
Seance5-6/seance/src/view/VuePartie4.php | 42 +++++++++++++++++++
4 files changed, 65 insertions(+), 12 deletions(-)
create mode 100644 Seance5-6/seance/src/view/VuePartie4.php
diff --git a/Seance5-6/seance/index.php b/Seance5-6/seance/index.php
index a035d74..c4bd7c1 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 728087e..4505ac9 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 1967e6b..1a7f1ad 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 0000000..59a74e9
--- /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
--
GitLab