From 4aff3b5a58db0748a0df75274c2769c4593d6ced Mon Sep 17 00:00:00 2001 From: palevrault Date: Tue, 30 Jan 2024 17:17:14 +0100 Subject: [PATCH] Ajout --- .../src/app/controller/AthleteController.php | 2 +- .../src/data/core/database/EnvoiEntity.php | 28 ++++++++++++ Sources/src/data/core/database/EnvoiGateway | 25 +++++++++++ Sources/src/data/core/database/EnvoiMapper | 44 +++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 Sources/src/data/core/database/EnvoiEntity.php create mode 100644 Sources/src/data/core/database/EnvoiGateway create mode 100644 Sources/src/data/core/database/EnvoiMapper diff --git a/Sources/src/app/controller/AthleteController.php b/Sources/src/app/controller/AthleteController.php index d7b2a71c..582b630c 100644 --- a/Sources/src/app/controller/AthleteController.php +++ b/Sources/src/app/controller/AthleteController.php @@ -106,7 +106,7 @@ class AthleteController extends BaseController 'taille' => $user->getTaille(), 'poids' => $user->getPoids(), 'motdepasse' => $user->getMotDePasse(), 'datenaissance' => $user->getDateNaissance(), 'iscoach' => $user->getRole(), 'img' => 'test', 'username' => $user->getUsername()]; - } + } $response = $this->render('./page/addfriend.html.twig',[ 'css' => $_COOKIE['preferences'], diff --git a/Sources/src/data/core/database/EnvoiEntity.php b/Sources/src/data/core/database/EnvoiEntity.php new file mode 100644 index 00000000..1047ef86 --- /dev/null +++ b/Sources/src/data/core/database/EnvoiEntity.php @@ -0,0 +1,28 @@ +idActivity; + } + + public function getIdNotif() { + return $this->type; + } + + // Setters + public function setIdAthlete($idAthlete) { + $this->idAthlete = $idAthlete; + } + + public function setIdNotif($idNotif) { + $this->idNotif = $idNotif; + } +} + +?> diff --git a/Sources/src/data/core/database/EnvoiGateway b/Sources/src/data/core/database/EnvoiGateway new file mode 100644 index 00000000..4f2fa732 --- /dev/null +++ b/Sources/src/data/core/database/EnvoiGateway @@ -0,0 +1,25 @@ +connection = $connection; + } + + public function getEnvois(): array + { + $query = "SELECT * FROM Envoi"; + $res = $this->connection->executeWithErrorHandling($query); + return $res; + } + + public function addEnvoi(EnvoiEntity $envoi){ + $query = "INSERT INTO Envoi (idAthlete, idEnvoi) VALUES (:idAthlete, :idEnvoi)"; + $params = [':idAthlete'=>$envoi->getIdAthlete(), ':date'=>$idNotif->getIdNotif()]; + return $this->connection->executeWithErrorHandling($query, $params); + } +} \ No newline at end of file diff --git a/Sources/src/data/core/database/EnvoiMapper b/Sources/src/data/core/database/EnvoiMapper new file mode 100644 index 00000000..6ce200d4 --- /dev/null +++ b/Sources/src/data/core/database/EnvoiMapper @@ -0,0 +1,44 @@ +setIdNotif($envoiData['idNotif']); + } + + if (isset($envoiData['idAthlete'])) { + $envoi->setMessage($envoiData['idAthlete']); + } + + $envoiEntities[] = $envoi; + } + + return $envoiEntities; + } + + public function envoiEntityToModel(EnvoiEntity $envoiEntity): Envoi + { + $date = new DateTime($envoiEntity->getDate()); + return new envoi( + $envoiEntity->getIdAthlete(), + $envoiEntity->getIdNotif(), + ); + } + + public function envoiToEntity(Envoi $envoi): EnvoiEntity + { + $notif = new envoiEntity(); + $notif->setIdAthlete($envoi->getIdAthlete()); + $notif->setIdNotif($envoi->getIdNotif()); + return $notif; + } +} \ No newline at end of file