diff --git a/public/index.php b/public/index.php index f95879f..eb580ce 100644 --- a/public/index.php +++ b/public/index.php @@ -6,7 +6,6 @@ require "../sql/database.php"; require "utils.php"; require "../src/react-display.php"; - use App\Connexion; use App\Controller\FrontController; use App\Controller\EditorController; @@ -21,16 +20,19 @@ use App\Validation\ValidationFail; use App\Controller\ErrorController; session_start(); + $basePath = get_public_path(); -var_dump($basePath); $con = new Connexion(get_database()); global $dictActionRole; $dictActionRole = [ "UserController" => "public", - "EditionUserController" => "editor" + "EditionUserController" => "public" ]; -$frontController = new FrontController($con, $basePath, $dictActionRole); -$frontController->run(); +$dict = [ + "new"; +] +$frontController = new FrontController($con, $basePath, $dictActionRole); +$frontController->run(); \ No newline at end of file diff --git a/src/Controller/FrontController.php b/src/Controller/FrontController.php index 337b3ca..6d265f6 100644 --- a/src/Controller/FrontController.php +++ b/src/Controller/FrontController.php @@ -41,11 +41,12 @@ class FrontController{ $match = $this->router->match(); if ($this->validMatch($match)){ - $this->roleControl($match['target']); + var_dump($match); + $this->controlRoute($match['target']); } else { $this->displayByViewKind(ViewHttpResponse::twig("error.html.twig", [], HttpCodes::NOT_FOUND)); } - // $this->roleControl($match["target"]); + // $this->controlRoute($match["target"]); // $this->handleByResponseType($this->matchRoute()); } @@ -86,23 +87,15 @@ class FrontController{ * * @return ViewHttpResponse */ - private function roleControl(string $actionController){ - + private function controlRoute(string $tag){ if (isset($_SESSION['role'])){ - if($_SESSION['role'] = $this->dictControllerRole[$actionController]){ - echo "Là on redirige vers le bon controller"; + if($_SESSION['role'] = $this->dictControllerRole[$tag]){ + $controller = new $tag(); } } else { - $_SESSION['role'] - echo "session initialisé"; + $_SESSION['role'] = 'public'; // Remplacer par appel de la méthode de connexion } - - - - - - // // Page not found // if ($match == null) { @@ -117,7 +110,9 @@ class FrontController{ } - + private function controlRole($match){ + + } /** * Redirect the return of the response by the response's type *