diff --git a/TP4/ex1/app/helpers/views.php b/TP4/ex1/app/helpers/views.php index b284f36eb5c641609549817fc7c400b6c7315d0e..2546cdb1d76d4592e6a83c8b497914350cacb3a7 100644 --- a/TP4/ex1/app/helpers/views.php +++ b/TP4/ex1/app/helpers/views.php @@ -1,6 +1,7 @@ <?php require_once("app/models/View.php"); /** + * Charge le contenu d'une vue avec des paramètres. * @param string $viewName * @param array $args * @return string diff --git a/TP4/ex1/app/models/View.php b/TP4/ex1/app/models/View.php index 2d8f7701256563709c789a07d80017777d2ba647..215012d0ca3288f77c001e3e3ba3a95d3d576eb8 100644 --- a/TP4/ex1/app/models/View.php +++ b/TP4/ex1/app/models/View.php @@ -83,6 +83,11 @@ class View return $viewContent; } + /** + * @param string $viewCode + * @param array $args + * @return string + */ public static function render(string $viewCode, array $args = []): string { extract($args); diff --git a/TP4/ex1/controller/ControleurAdherent.php b/TP4/ex1/controller/ControleurAdherent.php index b4900c608c4147057656cf64702924ffce00eba0..3b12d304fca8b37e884402e1bf9368a7a76bf9e1 100644 --- a/TP4/ex1/controller/ControleurAdherent.php +++ b/TP4/ex1/controller/ControleurAdherent.php @@ -3,13 +3,23 @@ require_once("models/Adherent.php"); class ControleurAdherent { - public static function lireAdherents() + /** + * Charge la page de la liste des adhérents. + * @return string + * @throws Exception + */ + public static function lireAdherents(): string { $adherents = Adherent::getAllAdherents(); return view('adherents.les-adherents', ['adherents' => $adherents]); } - public static function lireAdherent() + /** + * Charge la page du détail d'un adhérent. + * @return string + * @throws Exception + */ + public static function lireAdherent(): string { if (empty($_GET["login"])) { die("Le paramètre login n'est pas spécifié."); diff --git a/TP4/ex1/controller/ControleurAuteur.php b/TP4/ex1/controller/ControleurAuteur.php index 9a80bab36ca2a4bd322bf4f221c26894b322ea9e..08a476c526a4c376fbfdfdc5f78bc5b691f3050a 100644 --- a/TP4/ex1/controller/ControleurAuteur.php +++ b/TP4/ex1/controller/ControleurAuteur.php @@ -1,15 +1,26 @@ <?php require_once("models/Auteur.php"); +/** + * + */ class ControleurAuteur { - public static function lireAuteurs() + /** + * Charge la page de la liste des auteurs. + * @return string + */ + public static function lireAuteurs() : string { $auteurs = Auteur::getAllAuteurs(); return view('auteurs.les-auteurs', ['auteurs' => $auteurs]); } - public static function lireAuteur() + /** + * Charge la page du détail d'un auteur. + * @return string + */ + public static function lireAuteur() : string { if (empty($_GET["numAuteur"])) { die("Le paramètre numAuteur n'est pas spécifié."); diff --git a/TP4/ex1/index.php b/TP4/ex1/index.php index 3bf1b9cc2e6bdc097c35efb87f3716b55713a1fe..9c113ffb562f43c42a979d5a70042fae9d49afe4 100644 --- a/TP4/ex1/index.php +++ b/TP4/ex1/index.php @@ -12,13 +12,13 @@ require_once("controller/ControleurAdherent.php"); Database::connect(); -if(empty($_GET["action"])){ +if (empty($_GET["action"])) { echo ControleurAuteur::lireAuteurs(); -}else{ - if(in_array($_GET["action"], get_class_methods('ControleurAuteur'))){ +} else { + if (in_array($_GET["action"], get_class_methods('ControleurAuteur'))) { $action = $_GET["action"]; echo ControleurAuteur::$action(); - }elseif(in_array($_GET["action"], get_class_methods('ControleurAdherent'))){ + } elseif (in_array($_GET["action"], get_class_methods('ControleurAdherent'))) { $action = $_GET["action"]; echo ControleurAdherent::$action(); } diff --git a/TP4/ex1/models/Adherent.php b/TP4/ex1/models/Adherent.php index 9b09e4c2bad3d41fc3a2d6004219117eb65f0ae9..60de2e832697f8ac68b66a4611fd1e6323a69902 100644 --- a/TP4/ex1/models/Adherent.php +++ b/TP4/ex1/models/Adherent.php @@ -33,6 +33,10 @@ class Adherent $this->numCategorie = $numCategorie; } + /** + * @return array + * @throws Exception + */ public static function getAllAdherents(): array { // écriture de la requête @@ -56,6 +60,12 @@ class Adherent return $tableau; } + /** + * Trouve un adhérent selon son login unique. + * @param $login + * @return Adherent + * @throws Exception + */ public static function getAdherentByLogin($login) : Adherent { // écriture de la requête