From 2c89c0ec184c0ed76562c899722bb3615cd83add Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 26 Jul 2026 13:42:25 +0200 Subject: =?UTF-8?q?choix=20d'une=20strat=C3=A9gie=20par=20type=20d'objet,?= =?UTF-8?q?=20suppression=20des=20isset=20inutiles,=20suppression=20de=20$?= =?UTF-8?q?validated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/ContactFormController.php | 4 ++-- src/controller/UserController.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/controller') diff --git a/src/controller/ContactFormController.php b/src/controller/ContactFormController.php index cbc1837..e078af2 100644 --- a/src/controller/ContactFormController.php +++ b/src/controller/ContactFormController.php @@ -28,7 +28,7 @@ class ContactFormController } static public function setEmailParam(EntityManager $entityManager, array $json): JsonResponse { - $form = new FormValidation($json, 'email_params'); + $form = new FormValidation($json, ValidationStrategy::EmailParam); if($form->validate()){ $form_data = $entityManager->find(EmailForm::class, $json['id']); @@ -45,7 +45,7 @@ class ContactFormController // les deux méthodes suivantes sont "factorisables", elles ne se distinguent que par la gestion ou non du formulaire rempli par le visiteur static public function sendVisitorEmail(EntityManager $entityManager, array $json): JsonResponse { - $form = new FormValidation($json, 'email_send'); + $form = new FormValidation($json, ValidationStrategy::EmailSend); $error = ''; if($form->validate()){ diff --git a/src/controller/UserController.php b/src/controller/UserController.php index 03686ee..750b01b 100644 --- a/src/controller/UserController.php +++ b/src/controller/UserController.php @@ -25,7 +25,7 @@ class UserController { unset($_SESSION['user']); - $form = new FormValidation($_POST, 'create_user'); + $form = new FormValidation($_POST, ValidationStrategy::CreateUser); $url = new URL; $error = ''; @@ -58,7 +58,7 @@ class UserController } unset($_SESSION['user']); - $form = new FormValidation($_POST, 'connection'); + $form = new FormValidation($_POST, ValidationStrategy::Connection); $error = ''; if($form->validate()){ @@ -135,7 +135,7 @@ class UserController $url = new URL(['page' => 'user_edit']); isset($_GET['from']) ? $url->addParams(['from' => $_GET['from']]) : null; - $form = new FormValidation($_POST, 'username_update'); + $form = new FormValidation($_POST, ValidationStrategy::UsernameUpdate); $error = ''; if($form->validate()){ @@ -174,7 +174,7 @@ class UserController $url = new URL(['page' => 'user_edit']); isset($_GET['from']) ? $url->addParams(['from' => $_GET['from']]) : null; - $form = new FormValidation($_POST, 'password_update'); + $form = new FormValidation($_POST, ValidationStrategy::PasswordUpdate); $error = ''; if($form->validate()){ -- cgit v1.2.3