Add start of homepage and FrontControler (don't run it)
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
6aeefad564
commit
5737bd6e6b
@ -0,0 +1,8 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
class FrontController {
|
||||||
|
- router : AltoRouter
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class FrontController{
|
||||||
|
|
||||||
|
private AltoRouter $router;
|
||||||
|
private UserControler $userControler;
|
||||||
|
|
||||||
|
|
||||||
|
public function FrontController(AltoRouter $router){
|
||||||
|
$this->router = $router;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function main() {
|
||||||
|
$this->toRoute();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function toRoute(){
|
||||||
|
$this->router->map("GET", "/", fn() => $this->userControler->home());
|
||||||
|
// $this->router->map("POST", "/submit", fn() => $sampleFormController->submitForm($_POST));
|
||||||
|
// $this->router->map("GET", "/twig", fn() => $sampleFormController->displayFormTwig());
|
||||||
|
// $this->router->map("POST", "/submit-twig", fn() => $sampleFormController->submitFormTwig($_POST));
|
||||||
|
|
||||||
|
$match = $router->match();
|
||||||
|
|
||||||
|
// À remplacer par l'appel du contrôler d'erreur
|
||||||
|
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($match['target']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue