WIP
continuous-integration/drone/push Build is passing Details

pull/17/head
DahmaneYanis 1 year ago
parent 61a6b5afd5
commit 5314c3bd2d

@ -6,7 +6,6 @@ require "../sql/database.php";
require "utils.php"; require "utils.php";
require "../src/react-display.php"; require "../src/react-display.php";
use App\Connexion; use App\Connexion;
use App\Controller\FrontController; use App\Controller\FrontController;
use App\Controller\EditorController; use App\Controller\EditorController;
@ -21,16 +20,19 @@ use App\Validation\ValidationFail;
use App\Controller\ErrorController; use App\Controller\ErrorController;
session_start(); session_start();
$basePath = get_public_path(); $basePath = get_public_path();
var_dump($basePath);
$con = new Connexion(get_database()); $con = new Connexion(get_database());
global $dictActionRole; global $dictActionRole;
$dictActionRole = [ $dictActionRole = [
"UserController" => "public", "UserController" => "public",
"EditionUserController" => "editor" "EditionUserController" => "public"
]; ];
$frontController = new FrontController($con, $basePath, $dictActionRole); $dict = [
$frontController->run(); "new";
]
$frontController = new FrontController($con, $basePath, $dictActionRole);
$frontController->run();

@ -41,11 +41,12 @@ class FrontController{
$match = $this->router->match(); $match = $this->router->match();
if ($this->validMatch($match)){ if ($this->validMatch($match)){
$this->roleControl($match['target']); var_dump($match);
$this->controlRoute($match['target']);
} else { } else {
$this->displayByViewKind(ViewHttpResponse::twig("error.html.twig", [], HttpCodes::NOT_FOUND)); $this->displayByViewKind(ViewHttpResponse::twig("error.html.twig", [], HttpCodes::NOT_FOUND));
} }
// $this->roleControl($match["target"]); // $this->controlRoute($match["target"]);
// $this->handleByResponseType($this->matchRoute()); // $this->handleByResponseType($this->matchRoute());
} }
@ -86,23 +87,15 @@ class FrontController{
* *
* @return ViewHttpResponse * @return ViewHttpResponse
*/ */
private function roleControl(string $actionController){ private function controlRoute(string $tag){
if (isset($_SESSION['role'])){ if (isset($_SESSION['role'])){
if($_SESSION['role'] = $this->dictControllerRole[$actionController]){ if($_SESSION['role'] = $this->dictControllerRole[$tag]){
echo "Là on redirige vers le bon controller"; $controller = new $tag();
} }
} }
else { else {
$_SESSION['role'] $_SESSION['role'] = 'public'; // Remplacer par appel de la méthode de connexion
echo "session initialisé";
} }
// // Page not found // // Page not found
// if ($match == null) { // if ($match == null) {
@ -117,7 +110,9 @@ class FrontController{
} }
private function controlRole($match){
}
/** /**
* Redirect the return of the response by the response's type * Redirect the return of the response by the response's type
* *

Loading…
Cancel
Save