From ec474617035ab589fdc5e6ee2fe385c40b58b78f Mon Sep 17 00:00:00 2001 From: d_yanis Date: Tue, 14 Nov 2023 15:57:24 +0100 Subject: [PATCH] wip FRONT CONTROLLER --- composer.json | 1 + public/index.php | 11 +++-------- src/Controller/FrontController.php | 8 +++++--- src/Controller/UserController.php | 13 +++++++++++++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index c78fb15..0f5e1f2 100644 --- a/composer.json +++ b/composer.json @@ -11,4 +11,5 @@ "ext-pdo_sqlite": "*", "twig/twig":"^2.0" } + } \ No newline at end of file diff --git a/public/index.php b/public/index.php index d1fee44..d4e227e 100644 --- a/public/index.php +++ b/public/index.php @@ -3,6 +3,7 @@ require "../vendor/autoload.php"; require "../config.php"; require "../sql/database.php"; +require "../src/Controller/FrontController.php"; use \Twig\Loader\FilesystemLoader; use App\Connexion; @@ -34,12 +35,6 @@ $con = new Connexion(get_database()); $router = new AltoRouter(); $router->setBasePath($basePath); -$frontController = new FrontController($router); - -//$sampleFormController = new SampleFormController(new FormResultGateway($con), $twig); - - - - - +$frontController = new FrontController($router, new UserController()); +//$sampleFormController = new SampleFormController(new FormResultGateway($con), $twig); \ No newline at end of file diff --git a/src/Controller/FrontController.php b/src/Controller/FrontController.php index dcee0b1..7a1179b 100644 --- a/src/Controller/FrontController.php +++ b/src/Controller/FrontController.php @@ -1,14 +1,16 @@ router = $router; + $this->userControler = $userControler; } public function main() { @@ -22,7 +24,7 @@ class FrontController{ // $this->router->map("GET", "/twig", fn() => $sampleFormController->displayFormTwig()); // $this->router->map("POST", "/submit-twig", fn() => $sampleFormController->submitFormTwig($_POST)); - $match = $router->match(); + $match = $this->router->match(); // À remplacer par l'appel du contrôler d'erreur if ($match == null) { diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index e69de29..0934a04 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -0,0 +1,13 @@ +Welcome!"; + } + +} +?> \ No newline at end of file