updates controllers

master
Antoine PEREDERII 1 year ago
parent a5b3648320
commit 0f59ed962c

@ -1,31 +1,31 @@
<?php <?php
// namespace App\Controller; namespace App\Controller;
// use App\Container; use App\Container;
// use App\Router\Request\IRequest; use App\Router\Request\IRequest;
// use App\Router\Response\Response; use App\Router\Response\Response;
// use App\Router\Response\IResponse; use App\Router\Response\IResponse;
// use Shared\Attributes\Route; use Shared\Attributes\Route;
// use Twig\Environment; use Twig\Environment;
// use Data\Core\Preferences; use Data\Core\Preferences;
// use Shared\Log; use Shared\Log;
// #[Route(path: '/coach', name: 'coach')] #[Route(path: '/coach', name: 'coach')]
// class CoachController extends BaseController class CoachController extends BaseController
// { {
// private ICoachManager $coachManager; private ICoachManager $coachManager;
// private $security; private $security;
// public function __construct(DataManager $dataManager, Security $security) public function __construct(DataManager $dataManager, Security $security)
// { {
// $this->coachManager = $dataManager->coachMgr; $this->coachManager = $dataManager->coachMgr;
// $this->security = $security; $this->security = $security;
// } }
// #[Route(path: '/', name: 'home', methods: ['GET'])] // #[Route(path: '/', name: 'home', methods: ['GET'])]
// public function index(): Response // public function index(): Response
@ -44,7 +44,7 @@
// 'member' => [] // 'member' => []
// ]); // ]);
// } // }
//
// #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])] // #[Route('/global-stats', name: 'coach_global_stats', methods: ['GET'])]
// public function globalStats(): Response // public function globalStats(): Response
// { // {
@ -52,10 +52,194 @@
// return $this->render('coach/global_stats.html.twig'); // return $this->render('coach/global_stats.html.twig');
// } // }
// #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
// public function exercice(): Response public function exercice(): Response
{
return $this->render('./page/exercice.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => "Doe",
'role' => "Athlète",
'friendship' => [],
'analyzes' => [],
'mails' => [],
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]);
}
#[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
{
$exercicesArray = [
[
'date' => $date,
'type' => $type,
'intensite' => $intensite,
'status' => 'A venur',
]
];
return $this->render('./page/exercice.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => "Doe",
'role' => "Athlète",
'friendship' => [],
'analyzes' => [],
'mails' => [],
'users' => [],
'infoUser' => [],
'exos' => $exercicesArray,
'member' => []
]);
}
#[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
public function searchMember(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/addmember.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: '/add-member', name: 'add-member', methods: ['POST'])]
public function addmember(string $username, IRequest $req): Response
{
$taberror = [];
$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/addmember.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: '/member', name: 'member', methods: ['GET'])]
public function member(): Response
{
$utiliArray = [
[
'nom' => 'John',
'prenom' => 'Doe',
'img' => 'john_doe',
'username' => 'johndoe',
],
[
'nom' => 'Alice',
'prenom' => 'Smith',
'img' => 'alice_smith',
'username' => 'alicesmith',
],
];
return $this->render('./page/addmember.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => "Doe",
'role' => "Athlète",
'friendship' => [],
'analyzes' => [],
'mails' => [],
'users' => $utiliArray,
'infoUser' => [],
'exos' => [],
'member' => [],
]);
}
#[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
public function coaching(): Response
{
return $this->render('./page/coaching.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => "Doe",
'role' => "Athlète",
'friendship' => [],
'analyzes' => [],
'mails' => [],
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]);
}
// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
// public function coaching(): Response
// { // {
// return $this->render('./page/exercice.html.twig',[ // return $this->render('./page/coaching.html.twig',[
// 'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
// 'pp' => "test2", // 'pp' => "test2",
// 'user' => "Doe", // 'user' => "Doe",
@ -69,32 +253,13 @@
// 'member' => [] // 'member' => []
// ]); // ]);
// } // }
//
// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
// public function coaching(): Response
// {
// return $this->render('./page/coaching.html.twig',[
// 'css' => $this->preference->getCookie(),
// 'pp' => "test2",
// 'user' => "Doe",
// 'role' => "Athlète",
// 'friendship' => [],
// 'analyzes' => [],
// 'mails' => [],
// 'users' => [],
// 'infoUser' => [],
// 'exos' => [],
// 'member' => []
// ]);
// }
// #[Route('/list-athletes', name: 'coach_list_athletes')] // #[Route('/list-athletes', name: 'coach_list_athletes')]
// public function listAthletes(): Response // public function listAthletes(): Response
// { // {
// $coach = $this->security->getUser(); // $coach = $this->security->getUser();
// $athletes = $this->coachManager->getAthletesForCoach($coach); // $athletes = $this->coachManager->getAthletesForCoach($coach);
//
// return $this->render('coach/list_athletes.html.twig', [ // return $this->render('coach/list_athletes.html.twig', [
// 'athletes' => $athletes, // 'athletes' => $athletes,
// ]); // ]);
@ -107,22 +272,23 @@
// 'athleteId' => $athleteId, // 'athleteId' => $athleteId,
// ]); // ]);
// } // }
//
// #[Route('/add-athlete/{athleteId}', name: 'coach_add_athlete', methods: ['POST'])] // #[Route('/add-athlete/{athleteId}', name: 'coach_add_athlete', methods: ['POST'])]
// public function addAthlete(IRequest $request, $athleteId): IResponse // public function addAthlete(IRequest $request, $athleteId): IResponse
// { // {
// // Implement logic to add athlete // // Implement logic to add athlete
// // ... // // ...
//
// return $this->redirectToRoute('coach_list_athletes'); // return $this->redirectToRoute('coach_list_athletes');
// } // }
// // #[Route('/remove-athlete', name: 'coach_remove_athlete', methods: ['POST'])] // #[Route('/remove-athlete', name: 'coach_remove_athlete', methods: ['POST'])]
// // public function removeAthlete(int $athleteId, IRequest $request): IResponse // public function removeAthlete(int $athleteId, IRequest $request): IResponse
// // { // {
// // return $this->redirectToRoute("/athletes"); // return $this->redirectToRoute("/athletes");
// // } // }
// } }
?>

@ -76,49 +76,49 @@ class Controller extends BaseController
]); ]);
} }
#[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8 // #[Route(path: '/exercice', name: 'exercice', methods: ['GET'])] // 8
public function exercice(): Response // public function exercice(): Response
{ // {
return $this->render('./page/exercice.html.twig',[ // return $this->render('./page/exercice.html.twig',[
'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
'pp' => "test2", // 'pp' => "test2",
'user' => "Doe", // 'user' => "Doe",
'role' => "Athlète", // 'role' => "Athlète",
'friendship' => [], // 'friendship' => [],
'analyzes' => [], // 'analyzes' => [],
'mails' => [], // 'mails' => [],
'users' => [], // 'users' => [],
'infoUser' => [], // 'infoUser' => [],
'exos' => [], // 'exos' => [],
'member' => [] // 'member' => []
]); // ]);
} // }
//
#[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8 // #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
public function exercices(String $type, String $intensite, String $date, IRequest $req): Response // public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
{ // {
$exercicesArray = [ // $exercicesArray = [
[ // [
'date' => $date, // 'date' => $date,
'type' => $type, // 'type' => $type,
'intensite' => $intensite, // 'intensite' => $intensite,
'status' => 'A venur', // 'status' => 'A venur',
] // ]
]; // ];
return $this->render('./page/exercice.html.twig',[ // return $this->render('./page/exercice.html.twig',[
'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
'pp' => "test2", // 'pp' => "test2",
'user' => "Doe", // 'user' => "Doe",
'role' => "Athlète", // 'role' => "Athlète",
'friendship' => [], // 'friendship' => [],
'analyzes' => [], // 'analyzes' => [],
'mails' => [], // 'mails' => [],
'users' => [], // 'users' => [],
'infoUser' => [], // 'infoUser' => [],
'exos' => $exercicesArray, // 'exos' => $exercicesArray,
'member' => [] // 'member' => []
]); // ]);
} // }
#[Route(path: '/search-user', name: 'search-user', methods: ['GET'])] #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
public function searchUser(string $username, IRequest $req): Response public function searchUser(string $username, IRequest $req): Response
@ -165,94 +165,94 @@ class Controller extends BaseController
} }
#[Route(path: '/search-member', name: 'search-member', methods: ['GET'])] // #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
public function searchMember(string $username, IRequest $req): Response // public function searchMember(string $username, IRequest $req): Response
{ // {
$taberror = []; // $taberror = [];
// FILTER // // FILTER
$utiliArray = [ // $utiliArray = [
[ // [
'nom' => 'John', // 'nom' => 'John',
'prenom' => 'Doe', // 'prenom' => 'Doe',
'img' => 'john_doe', // 'img' => 'john_doe',
'username' => 'johndoe', // 'username' => 'johndoe',
], // ],
[ // [
'nom' => 'Alice', // 'nom' => 'Alice',
'prenom' => 'Smith', // 'prenom' => 'Smith',
'img' => 'alice_smith', // 'img' => 'alice_smith',
'username' => 'alicesmith', // 'username' => 'alicesmith',
], // ],
]; // ];
// if(!Validation::val_string($name)){ // // if(!Validation::val_string($name)){
try { // try {
//code... // //code...
// $model->userMgr->addFriend($name); // // $model->userMgr->addFriend($name);
return $this->render('./page/addmember.html.twig',[ // return $this->render('./page/addmember.html.twig',[
'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
'pp' => "test2", // 'pp' => "test2",
'user' => "Doe", // 'user' => "Doe",
'role' => "Athlète", // 'role' => "Athlète",
'friendship' => [], // 'friendship' => [],
'analyzes' => [], // 'analyzes' => [],
'mails' => [], // 'mails' => [],
'users' => $utiliArray, // 'users' => $utiliArray,
'infoUser' => [], // 'infoUser' => [],
'exos' => [], // 'exos' => [],
'member' => [], // 'member' => [],
'responce' => "Notification d'ajout envoyée à $username" // 'responce' => "Notification d'ajout envoyée à $username"
]); // ]);
} catch (\Throwable $th) { // } catch (\Throwable $th) {
//throw $th; // //throw $th;
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); // // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
} // }
// } // // }
//
} // }
#[Route(path: '/add-member', name: 'add-member', methods: ['POST'])] // #[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
public function addmember(string $username, IRequest $req): Response // public function addmember(string $username, IRequest $req): Response
{ // {
$taberror = []; // $taberror = [];
$utiliArray = [ // $utiliArray = [
[ // [
'nom' => 'John', // 'nom' => 'John',
'prenom' => 'Doe', // 'prenom' => 'Doe',
'img' => 'john_doe', // 'img' => 'john_doe',
'username' => 'johndoe', // 'username' => 'johndoe',
], // ],
[ // [
'nom' => 'Alice', // 'nom' => 'Alice',
'prenom' => 'Smith', // 'prenom' => 'Smith',
'img' => 'alice_smith', // 'img' => 'alice_smith',
'username' => 'alicesmith', // 'username' => 'alicesmith',
], // ],
]; // ];
// if(!Validation::val_string($name)){ // // if(!Validation::val_string($name)){
try { // try {
//code... // //code...
// $model->userMgr->addFriend($name); // // $model->userMgr->addFriend($name);
return $this->render('./page/addmember.html.twig',[ // return $this->render('./page/addmember.html.twig',[
'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
'pp' => "test2", // 'pp' => "test2",
'user' => "Doe", // 'user' => "Doe",
'role' => "Athlète", // 'role' => "Athlète",
'friendship' => [], // 'friendship' => [],
'analyzes' => [], // 'analyzes' => [],
'mails' => [], // 'mails' => [],
'users' => $utiliArray, // 'users' => $utiliArray,
'infoUser' => [], // 'infoUser' => [],
'exos' => [], // 'exos' => [],
'member' => [], // 'member' => [],
'responce' => "Notification d'ajout envoyée à $username" // 'responce' => "Notification d'ajout envoyée à $username"
]); // ]);
} catch (\Throwable $th) { // } catch (\Throwable $th) {
//throw $th; // //throw $th;
// return $this->render("addfriend.html.twig", ['tabError' => $taberror ]); // // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
} // }
// } // // }
//
} // }
#[Route(path: '/member', name: 'member', methods: ['GET'])] #[Route(path: '/member', name: 'member', methods: ['GET'])]
public function member(): Response public function member(): Response
@ -432,23 +432,23 @@ class Controller extends BaseController
]); ]);
} }
#[Route(path: '/coaching', name: 'coaching', methods: ['GET'])] // #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
public function coaching(): Response // public function coaching(): Response
{ // {
return $this->render('./page/coaching.html.twig',[ // return $this->render('./page/coaching.html.twig',[
'css' => $this->preference->getCookie(), // 'css' => $this->preference->getCookie(),
'pp' => "test2", // 'pp' => "test2",
'user' => "Doe", // 'user' => "Doe",
'role' => "Athlète", // 'role' => "Athlète",
'friendship' => [], // 'friendship' => [],
'analyzes' => [], // 'analyzes' => [],
'mails' => [], // 'mails' => [],
'users' => [], // 'users' => [],
'infoUser' => [], // 'infoUser' => [],
'exos' => [], // 'exos' => [],
'member' => [] // 'member' => []
]); // ]);
} // }
#[Route(path: '/mail', name: 'mail', methods: ['GET'])] #[Route(path: '/mail', name: 'mail', methods: ['GET'])]
public function mail(): Response public function mail(): Response

Loading…
Cancel
Save