From 225b4d58e8249a3293e596d239f65f2cc5f33bad Mon Sep 17 00:00:00 2001 From: "antoine.pinagot" Date: Sun, 26 Nov 2023 23:46:27 +0100 Subject: [PATCH] try athelte controller --- Sources/config/config.php | 4 +- .../src/app/controller/AthleteController.php | 107 +++++++++--------- Sources/src/app/controller/Controller.php | 91 +++++++-------- 3 files changed, 100 insertions(+), 102 deletions(-) diff --git a/Sources/config/config.php b/Sources/config/config.php index f542a00c..d63ad388 100755 --- a/Sources/config/config.php +++ b/Sources/config/config.php @@ -4,7 +4,7 @@ use Dotenv\Dotenv; $dotenv = Dotenv::createImmutable(__DIR__); $dotenv->load(); -use Dotenv\Dotenv; + use Shared\Log; $dotenv = Dotenv::createUnsafeImmutable(__DIR__,'.env'); @@ -20,6 +20,6 @@ const DB_HOST = 'localhost'; const DB_DATABASE = 'heartTrack'; const DB_USER = 'toto'; const DB_PASSWORD = 'achanger'; -const APP_ENV = 'console'; +//const APP_ENV = 'console'; const DSN = "mysql:host=" . DB_HOST . ";dbname=" . DB_DATABASE; \ No newline at end of file diff --git a/Sources/src/app/controller/AthleteController.php b/Sources/src/app/controller/AthleteController.php index 54d49e87..901fe26f 100644 --- a/Sources/src/app/controller/AthleteController.php +++ b/Sources/src/app/controller/AthleteController.php @@ -1,62 +1,63 @@ 'John', -// 'prenom' => 'Doe', -// 'img' => 'john_doe', -// 'username' => 'johndoe', -// ], -// [ -// 'nom' => 'Alice', -// 'prenom' => 'Smith', -// 'img' => 'alice_smith', -// 'username' => 'alicesmith', -// ], -// ]; -// // if(!Validation::val_string($name)){ -// try { -// //code... -// // $model->userMgr->getUser($name); -// return $this->render('./page/addfriend.html.twig',[ -// 'css' => $this->preference->getCookie(), -// 'pp' => "test2", -// 'user' => "Doe", -// 'role' => "Athlète", -// 'friendship' => [], -// 'analyzes' => [], -// 'mails' => [], -// 'users' => $utiliArray, -// 'infoUser' => [], -// 'exos' => [], -// 'member' => [], -// 'responce' => "Notification d'ajout envoyée à $username" -// ]); -// } catch (\Throwable $th) { -// //throw $th; -// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); -// } -// // } + #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] + public function searchUser(string $username, IRequest $req): Response + { + $taberror = []; + // FILTER + $utiliArray = [ + [ + 'nom' => 'John', + 'prenom' => 'Doe', + 'img' => 'john_doe', + 'username' => 'johndoe', + ], + [ + 'nom' => 'Alice', + 'prenom' => 'Smith', + 'img' => 'alice_smith', + 'username' => 'alicesmith', + ], + ]; + // if(!Validation::val_string($name)){ + try { + //code... + $model->userMgr->addFriend($username); + return $this->render('./page/addfriend.html.twig',[ + 'css' => $this->preference->getCookie(), + 'pp' => "test2", + 'user' => "Doe", + 'role' => "Athlète", + 'friendship' => [], + 'analyzes' => [], + 'mails' => [], + 'users' => $utiliArray, + 'infoUser' => [], + 'exos' => [], + 'member' => [], + 'responce' => "Notification d'ajout envoyée à $username" + ]); + } catch (\Throwable $th) { + //throw $th; + // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); + } + // } -// } - + } +} // #[Route(path: '/analyses', name: 'analyses', methods: ['GET'])] // public function analyses(): Response // { diff --git a/Sources/src/app/controller/Controller.php b/Sources/src/app/controller/Controller.php index 7dddd5c5..29da6dd5 100644 --- a/Sources/src/app/controller/Controller.php +++ b/Sources/src/app/controller/Controller.php @@ -120,50 +120,50 @@ class Controller extends BaseController ]); } - #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] - public function searchUser(string $username, IRequest $req): Response - { - $taberror = []; - // FILTER - $utiliArray = [ - [ - 'nom' => 'John', - 'prenom' => 'Doe', - 'img' => 'john_doe', - 'username' => 'johndoe', - ], - [ - 'nom' => 'Alice', - 'prenom' => 'Smith', - 'img' => 'alice_smith', - 'username' => 'alicesmith', - ], - ]; - // if(!Validation::val_string($name)){ - try { - //code... - // $model->userMgr->addFriend($name); - return $this->render('./page/addfriend.html.twig',[ - 'css' => $this->preference->getCookie(), - 'pp' => "test2", - 'user' => "Doe", - 'role' => "Athlète", - 'friendship' => [], - 'analyzes' => [], - 'mails' => [], - 'users' => $utiliArray, - 'infoUser' => [], - 'exos' => [], - 'member' => [], - 'responce' => "Notification d'ajout envoyée à $username" - ]); - } catch (\Throwable $th) { - //throw $th; - // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); - } - // } + // #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] + // public function searchUser(string $username, IRequest $req): Response + // { + // $taberror = []; + // // FILTER + // $utiliArray = [ + // [ + // 'nom' => 'John', + // 'prenom' => 'Doe', + // 'img' => 'john_doe', + // 'username' => 'johndoe', + // ], + // [ + // 'nom' => 'Alice', + // 'prenom' => 'Smith', + // 'img' => 'alice_smith', + // 'username' => 'alicesmith', + // ], + // ]; + // // if(!Validation::val_string($name)){ + // try { + // //code... + // // $model->userMgr->addFriend($name); + // return $this->render('./page/addfriend.html.twig',[ + // 'css' => $this->preference->getCookie(), + // 'pp' => "test2", + // 'user' => "Doe", + // 'role' => "Athlète", + // 'friendship' => [], + // 'analyzes' => [], + // 'mails' => [], + // 'users' => $utiliArray, + // 'infoUser' => [], + // 'exos' => [], + // 'member' => [], + // 'responce' => "Notification d'ajout envoyée à $username" + // ]); + // } catch (\Throwable $th) { + // //throw $th; + // // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); + // } + // // } - } + // } #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])] public function searchMember(string $username, IRequest $req): Response @@ -712,7 +712,4 @@ class Controller extends BaseController ]); } -} - - - +} \ No newline at end of file