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.
56 lines
1.5 KiB
56 lines
1.5 KiB
1 year ago
|
<?php
|
||
|
namespace controleur;
|
||
|
|
||
|
class FrontControleur
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
global $twig; // nécessaire pour utiliser variables globales
|
||
|
// on démarre ou reprend la session pas utilisée ici
|
||
|
session_start();
|
||
|
|
||
|
//debut
|
||
|
//on initialise un tableau d'erreur
|
||
|
$dVueEreur = [];
|
||
|
|
||
|
try {
|
||
|
$action = $_REQUEST['action'] ?? null;
|
||
|
|
||
|
switch($action) {
|
||
|
//pas d'action, on réinitialise 1er appel
|
||
|
case null:
|
||
|
$this->reinit();
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
$dVueEreur[] = "Erreur d'appel php";
|
||
|
echo $twig->render('accueil.html', ['dVueEreur' => $dVueEreur]);
|
||
|
break;
|
||
|
}
|
||
|
} catch (\PDOException $e) {
|
||
|
//si erreur BD, pas le cas ici
|
||
|
$dVueEreur[] = 'Erreur inattendue!!! ';
|
||
|
} catch (\Exception $e2) {
|
||
|
$dVueEreur[] = 'Erreur inattendue!!! ';
|
||
|
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
|
||
|
}
|
||
|
|
||
|
//fin
|
||
|
exit(0);
|
||
|
}//fin constructeur
|
||
|
|
||
|
public function reinit()
|
||
|
{
|
||
|
global $twig; // nécessaire pour utiliser variables globales
|
||
|
|
||
|
$dVue = [
|
||
|
'nom' => '',
|
||
|
'age' => 0,
|
||
|
];
|
||
|
echo $twig->render('accueil.html', [
|
||
|
'dVue' => $dVue
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
}
|