From 94dafd735ce7fa0c5a2154b12deb98f23fdb3363 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:31:06 +0100 Subject: [PATCH] switch code to english --- Controleurs/ControleurHelloworld.php | 19 ----- Controllers/HelloworldController.php | 19 +++++ Kernel/AutoLoad.php | 54 +++++++++++++ Kernel/Constants.php | 42 ++++++++++ Kernel/Controller.php | 71 +++++++++++++++++ Kernel/Exceptions/ControllerException.php | 3 + {Noyau => Kernel}/Model.php | 0 Kernel/View.php | 24 ++++++ {Modele => Models}/Helloworld.php | 0 Noyau/ChargementAuto.php | 55 ------------- Noyau/Constantes.php | 46 ----------- Noyau/Controleur.php | 77 ------------------- Noyau/Exceptions/ControleurException.php | 3 - Noyau/Vue.php | 27 ------- .../pied.php => Views/common/footer.php | 0 .../entete.php => Views/common/header.php | 4 +- {Vues => Views}/helloworld/testform.php | 0 Views/helloworld/view.php | 3 + Vues/gabarit.php => Views/html.php | 22 +++--- Vues/helloworld/voir.php | 3 - index.php | 38 +++------ 21 files changed, 239 insertions(+), 271 deletions(-) delete mode 100644 Controleurs/ControleurHelloworld.php create mode 100644 Controllers/HelloworldController.php create mode 100644 Kernel/AutoLoad.php create mode 100644 Kernel/Constants.php create mode 100644 Kernel/Controller.php create mode 100644 Kernel/Exceptions/ControllerException.php rename {Noyau => Kernel}/Model.php (100%) create mode 100644 Kernel/View.php rename {Modele => Models}/Helloworld.php (100%) delete mode 100644 Noyau/ChargementAuto.php delete mode 100644 Noyau/Constantes.php delete mode 100644 Noyau/Controleur.php delete mode 100644 Noyau/Exceptions/ControleurException.php delete mode 100644 Noyau/Vue.php rename Vues/standard/pied.php => Views/common/footer.php (100%) rename Vues/standard/entete.php => Views/common/header.php (96%) rename {Vues => Views}/helloworld/testform.php (100%) create mode 100644 Views/helloworld/view.php rename Vues/gabarit.php => Views/html.php (57%) delete mode 100644 Vues/helloworld/voir.php diff --git a/Controleurs/ControleurHelloworld.php b/Controleurs/ControleurHelloworld.php deleted file mode 100644 index 68019a1..0000000 --- a/Controleurs/ControleurHelloworld.php +++ /dev/null @@ -1,19 +0,0 @@ - $O_helloworld->donneMessage())); - - } - - public function testformAction(Array $A_parametres = null, Array $A_postParams = null) - { - - Vue::montrer('helloworld/testform', array('formData' => $A_postParams)); - - } - -} \ No newline at end of file diff --git a/Controllers/HelloworldController.php b/Controllers/HelloworldController.php new file mode 100644 index 0000000..448a2c8 --- /dev/null +++ b/Controllers/HelloworldController.php @@ -0,0 +1,19 @@ + $O_helloworld->donneMessage())); + + } + + public function testformAction(Array $A_urlParams = null, Array $A_postParams = null) + { + + View::show('helloworld/testform', array('formData' => $A_postParams)); + + } + +} \ No newline at end of file diff --git a/Kernel/AutoLoad.php b/Kernel/AutoLoad.php new file mode 100644 index 0000000..230177e --- /dev/null +++ b/Kernel/AutoLoad.php @@ -0,0 +1,54 @@ +_A_urlParts['controller'] = array_shift($_A_urlParts); + $this->_A_urlParts['action'] = array_shift($_A_urlParts); + + $this->_A_urlParametres = $_A_urlParts; + + $this->_A_postParams = $A_postParams; + + + } + + // Execute the controller and action deduced + + public function execute() + { + if (!class_exists($this->_A_urlParts['controller'])) { + throw new ControllerException("Controller " . $this->_A_urlParts['controller'] . " is not valid."); + } + + if (!method_exists($this->_A_urlParts['controller'], $this->_A_urlParts['action'])) { + throw new ControllerException("Action " . $this->_A_urlParts['action'] . " of controller " . + $this->_A_urlParts['controller'] . " is not valid."); + } + + + $B_called = call_user_func_array(array(new $this->_A_urlParts['controller'], + $this->_A_urlParts['action']), array($this->_A_urlParams, $this->_A_postParams )); + + if (false === $B_called) { + throw new ControllerException("Action " . $this->_A_urlParts['action'] . + " of controller " . $this->_A_urlParts['controller'] . " failed."); + } + } +} \ No newline at end of file diff --git a/Kernel/Exceptions/ControllerException.php b/Kernel/Exceptions/ControllerException.php new file mode 100644 index 0000000..b529795 --- /dev/null +++ b/Kernel/Exceptions/ControllerException.php @@ -0,0 +1,3 @@ +_A_urlDecortique['controleur'] = array_shift($A_urlDecortique); // on recupere le contrôleur - $this->_A_urlDecortique['action'] = array_shift($A_urlDecortique); // puis l'action - - // ...on stocke ces éventuels parametres dans la variable d'instance qui leur est réservée - $this->_A_urlParametres = $A_urlDecortique; - - // On s'occupe du tableau $A_postParams - $this->_A_postParams = $A_postParams; - - - } - - // On exécute notre triplet - - public function executer() - { - if (!class_exists($this->_A_urlDecortique['controleur'])) { - throw new ControleurException($this->_A_urlDecortique['controleur'] . " n'est pas un controleur valide."); - } - - if (!method_exists($this->_A_urlDecortique['controleur'], $this->_A_urlDecortique['action'])) { - throw new ControleurException($this->_A_urlDecortique['action'] . " du contrôleur " . - $this->_A_urlDecortique['controleur'] . " n'est pas une action valide."); - } - - $B_called = call_user_func_array(array(new $this->_A_urlDecortique['controleur'], - $this->_A_urlDecortique['action']), array($this->_A_urlParametres, $this->_A_postParams )); - - if (false === $B_called) { - throw new ControleurException("L'action " . $this->_A_urlDecortique['action'] . - " du contrôleur " . $this->_A_urlDecortique['controleur'] . " a rencontré une erreur."); - } - } -} \ No newline at end of file diff --git a/Noyau/Exceptions/ControleurException.php b/Noyau/Exceptions/ControleurException.php deleted file mode 100644 index 045e712..0000000 --- a/Noyau/Exceptions/ControleurException.php +++ /dev/null @@ -1,3 +0,0 @@ -