From 6ff667e3b8bcecb381f8d5b6f430cda65fa14149 Mon Sep 17 00:00:00 2001 From: "mael.daim" Date: Mon, 13 Nov 2023 22:12:51 +0100 Subject: [PATCH] WIP made a diagram class For team within MVC, players aren't incorporated yet --- Documentation/team.puml | 67 ++++++++++++++++++++++++++++++- public/index.php | 2 +- src/Controller/TeamController.php | 2 +- src/Gateway/TeamGateway.php | 2 +- src/Model/TeamModel.php | 2 +- src/Views/insertTeam.html.twig | 3 -- 6 files changed, 70 insertions(+), 8 deletions(-) diff --git a/Documentation/team.puml b/Documentation/team.puml index f775665..b8374cd 100644 --- a/Documentation/team.puml +++ b/Documentation/team.puml @@ -1,3 +1,68 @@ @startuml -/*todo*/ +class Team { + - name: String + - picture: Url + - members: array + + + getName(): String + + getPicture(): Url + + getMainColor(): Color + + getSecondColor(): Color + + listMembers(): array +} + +Team --> "- mainColor" Color +Team --> "- secondaryColor" Color + +class Color { + - value: int + + + getValue(): int +} + +class TeamGateway{ + -- + + __construct(con : Connexion) + + insert(name : string ,picture : string, mainColor : Color, secondColor : Color) + + listByName(name : string): array +} + +TeamGateway *--"- con" Connexion +TeamGateway ..> Color + +class TeamModel{ + + ERROR_INVALID_COLOR : int {readOnly} + + ERROR_INVALID_NAME : int {readOnly} + + ERROR_INVALID_PICTURE : int {readOnly} + + ERROR_INVALID_SEARCH : int {readOnly} + + ERROR_NO_DATA_FOUND : int {readOnly} + --- + + __construct(gateway : TeamGateway) + + createTeam(name : string,picture : string, mainColorValue : int, secondColorValue : int, errors : array) + + listByName(name : string ,errors : array) : ?array +} + +TeamModel *--"- gateway" TeamGateway +TeamModel ..> Team +TeamModel ..> Color + +class TeamController{ + - twig : Environement + -- + + __construct( model : TeamModel, twig : Environement) + + submitTeam(request : array) + + listTeamByName(request : array) +} + +TeamController *--"- model" TeamModel + +class Connexion{ + - pdo : PDO + -- + + __constructor(pdo : PDO) + + exec(query : string, args : array) + + fetch(query string, args array): array + +} + @enduml \ No newline at end of file diff --git a/public/index.php b/public/index.php index 88d90fa..816517d 100644 --- a/public/index.php +++ b/public/index.php @@ -40,7 +40,7 @@ $router->map("POST", "/submit", fn() => $sampleFormController->submitForm($_POST $router->map("GET", "/twig", fn() => $sampleFormController->displayFormTwig()); $router->map("POST", "/submit-twig", fn() => $sampleFormController->submitFormTwig($_POST)); -$teamController = new \App\Controller\TeamController(new \App\Model\TeamModel(),$twig); +$teamController = new \App\Controller\TeamController(new \App\Model\TeamModel(new \App\Gateway\TeamGateway($con)),$twig); $router->map("GET","/team/new", fn()=>$teamController->submitTeam($_POST)); $match = $router->match(); diff --git a/src/Controller/TeamController.php b/src/Controller/TeamController.php index 65e3f25..04d88e4 100644 --- a/src/Controller/TeamController.php +++ b/src/Controller/TeamController.php @@ -28,7 +28,7 @@ class TeamController /* verif si les camp sont assignés, sinon erreur 400*/ public function listTeamByName(array $request){ $errors = []; - $this->model->listByName($request['name'],$errors); + $results = $this->model->listByName($request['name'],$errors); if(!empty($errors)){ /*todo appelle vue avec param*/ } diff --git a/src/Gateway/TeamGateway.php b/src/Gateway/TeamGateway.php index 17462ea..f492411 100644 --- a/src/Gateway/TeamGateway.php +++ b/src/Gateway/TeamGateway.php @@ -26,7 +26,7 @@ class TeamGateway /* retourne exception par rapport à la validité du paramètr ); } - public function listByName($name): array { + public function listByName(string $name): array { return $this->con->fetch( "SELECT name,picture,mainColor,secondColor FROM Team WHERE name LIKE '% :thing %' ", [ diff --git a/src/Model/TeamModel.php b/src/Model/TeamModel.php index 6815ad6..d356672 100644 --- a/src/Model/TeamModel.php +++ b/src/Model/TeamModel.php @@ -10,7 +10,7 @@ class TeamModel /* throw des exceptions(ex validation des champs, filtre etc) po { /** - * Attributes used to + * Attributes used to handle errors */ public const ERROR_INVALID_COLOR = 0; public const ERROR_INVALID_NAME = 1; diff --git a/src/Views/insertTeam.html.twig b/src/Views/insertTeam.html.twig index 62f6553..0f68a9f 100644 --- a/src/Views/insertTeam.html.twig +++ b/src/Views/insertTeam.html.twig @@ -55,9 +55,6 @@ - - -

Créer une équipe