aed8ee26 |
<?php
|
daf6e125 |
namespace MVC\Classe;
|
aed8ee26 |
class Controlleur{
public $modele;
public $vue;
public function __construct($application){
|
ff461209 |
|
fa275ca6 |
switch ($application->http->method) {
|
3fb55a08 |
//cas des requètes PUT et DELETE
case 'PUT':
case 'DELETE':
case 'POST':
case 'GET':
|
fa275ca6 |
if ($application->browser->isAppRequest()) {
|
3fb55a08 |
require CONTROLLER_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . 'HttpReponse.php';
|
fa275ca6 |
$this->callHttpResponse($application);
|
3fb55a08 |
break;
}
default:
if ($application->url->page['control']) {
$url_params = $application->url->page['params'];
require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php';
} else {
$this->modele = new Modele($application->url->page);
$this->vue = new Vue($this);
}
|
3957c7ee |
}
|
3fb55a08 |
|
aed8ee26 |
}
|
fa275ca6 |
public function callHttpResponse($application)
{
$reponseHttp = "\\" . $application->url->page['name'] . 'HttpReponse';
//FIXME:
//Le passage par le contructeur dans le cas d'une instanciation dynamique ne fonctionne pas
//$reponse = new $reponseHttp($application->url, $application->http->getData());
//il faut passer par une fonction personnelle permettant l'instanciation des variables
$reponse = new $reponseHttp();
$reponse->instanciate($application->url, $application->http->getData());
$method = strtolower($application->http->method);
$this->vue = new VueVide();
ob_start();
$reponse->$method();
$this->vue->ecran = ob_get_clean();
return;
}
|
aed8ee26 |
}
|