@ -8,14 +8,15 @@ use model\MdlStudent;
class FrontController
class FrontController
{
{
public function __construct() {
public function __construct()
{
global $twig;
global $twig;
global $altorouterPath;
global $altorouterPath;
session_start();
session_start();
// var_dump($_SESSION['login']);
var_dump($_SESSION['login']);
// var_dump($_SESSION['roles']);
var_dump($_SESSION['roles']);
try {
try {
$router = new \AltoRouter();
$router = new \AltoRouter();
@ -29,10 +30,19 @@ class FrontController
$match = $router->match();
$match = $router->match();
if (!$match) { throw new Exception("Erreur 404");}
if (!$match) {
throw new Exception("Erreur 404");
}
if ($match) {
//list($controller, $action) = explode('#', $match['target'] );
$controller = $match['target'] ?? null;
$controller = $match['target'] ?? null;
$action = Validation::val_action($match['params']['action'] ?? null);
$action = Validation::val_action($match['params']['action'] ?? null);
$id = $match['params']['id'] ?? null;
print 'user Id received ' . $id . '< br > ';
print 'controleur appelé ' . $controller . '< br > ';
print $action . '< br > ';
print $id . '< br > ';
switch ($action) {
switch ($action) {
case null:
case null:
@ -57,12 +67,15 @@ class FrontController
break;
break;
}
}
}
}
catch (Exception $e) {
}
catch
(Exception $e) {
$dVueEreur[] = $e->getMessage();
$dVueEreur[] = $e->getMessage();
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
}
}
}
}
public function home(): void {
public function home(): void {
global $twig;
global $twig;
echo $twig->render('home.html');
echo $twig->render('home.html');