You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
<?php
|
|
|
|
namespace Controller;
|
|
|
|
use Exception;
|
|
use PDOException;
|
|
|
|
class FrontController
|
|
{
|
|
function __construct()
|
|
{
|
|
/* La liste de tous les Controller */
|
|
$listControllers = array("\\Controller\\ControllerCandidate", "\\Controller\\ControllerAdmin");
|
|
|
|
global $rep, $views; // Chemin d'accès + Vues
|
|
$dVueError = array(); // Vue d'erreur
|
|
|
|
try
|
|
{
|
|
/* Si l'action est NULL on appelle goToTestimony(), sinon on nettoie l'action */
|
|
$action = $_REQUEST['action'] ? $action = $_REQUEST['action'] : (new ControllerCandidate())->goToForm();
|
|
|
|
foreach ($listControllers as $controller) // Pour chaque Controller
|
|
{
|
|
/* On regarde s'il implémente une fonction du même nom que l'action reçue */
|
|
if(method_exists($controller, $action))
|
|
{
|
|
(new $controller)->$action(); // Si oui, on appelle cette fonction
|
|
}
|
|
}
|
|
} catch (PDOException|Exception $e)
|
|
{
|
|
$dVueError[] = "Erreur innatendue !"; // Ecriture du message d'erreur
|
|
echo "ERREUUUUUR";
|
|
}
|
|
|
|
exit(0);
|
|
}
|
|
} |