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.
49 lines
1.5 KiB
49 lines
1.5 KiB
<?php
|
|
|
|
require "../vendor/autoload.php";
|
|
require "../config.php";
|
|
require "../sql/database.php";
|
|
require "utils.php";
|
|
|
|
use \Twig\Loader\FilesystemLoader;
|
|
use App\Connexion;
|
|
use App\Controller\SampleFormController;
|
|
use App\Controller\EditorController;
|
|
|
|
use App\Gateway\FormResultGateway;
|
|
use App\Gateway\TacticInfoGateway;
|
|
|
|
use App\Model\TacticModel;
|
|
|
|
|
|
$loader = new FilesystemLoader('../src/Views/');
|
|
$twig = new \Twig\Environment($loader);
|
|
|
|
$basePath = get_public_path();
|
|
$con = new Connexion(get_database());
|
|
|
|
// routes initialization
|
|
$router = new AltoRouter();
|
|
$router->setBasePath($basePath);
|
|
|
|
$sampleFormController = new SampleFormController(new FormResultGateway($con), $twig);
|
|
$editorController = new EditorController(new TacticModel(new TacticInfoGateway($con)));
|
|
|
|
$router->map("GET", "/", fn() => $sampleFormController->displayForm());
|
|
$router->map("POST", "/submit", fn() => $sampleFormController->submitForm($_POST));
|
|
$router->map("GET", "/twig", fn() => $sampleFormController->displayFormTwig());
|
|
$router->map("POST", "/submit-twig", fn() => $sampleFormController->submitFormTwig($_POST));
|
|
$router->map("GET", "/tactic/new", fn() => $editorController->makeNew());
|
|
$router->map("GET", "/tactic/[i:id]/edit", fn(int $id) => $editorController->edit($id));
|
|
|
|
$match = $router->match();
|
|
|
|
if ($match == null) {
|
|
// TODO redirect to a 404 not found page instead (issue #1)
|
|
http_response_code(404);
|
|
echo "Page non trouvée";
|
|
exit(1);
|
|
}
|
|
|
|
call_user_func_array($match['target'], $match['params']);
|