Selecteur du controlleur depuis l'URL[1] réalisé. Si non ok, alors affichage de toutes les possiblitées.
This commit is contained in:
parent
7b996cc5f6
commit
4caafe16d5
|
@ -1,4 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require "../bootstrap.php";
|
require "../bootstrap.php";
|
||||||
use Src\Controller\CompteurController;
|
use Src\Controller\CompteurController;
|
||||||
|
|
||||||
|
@ -18,10 +22,13 @@ $endpoints = array(
|
||||||
'compteur',
|
'compteur',
|
||||||
'releve'
|
'releve'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
if ( ! in_array($uri[1], $endpoints) ) {
|
if ( ! in_array($uri[1], $endpoints) ) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// the user id is, of course, optional and must be a number:
|
// the user id is, of course, optional and must be a number:
|
||||||
$id = null;
|
$id = null;
|
||||||
|
@ -31,9 +38,18 @@ if (isset($uri[2])) {
|
||||||
|
|
||||||
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
$requestMethod = $_SERVER["REQUEST_METHOD"];
|
||||||
|
|
||||||
// pass the request method and user ID to the CompteurController and process the HTTP request:
|
switch($uri[1]) {
|
||||||
$qsd = CompteurController
|
case 'compteur':
|
||||||
$controller = new $qsd($dbConnection, $requestMethod, $id);
|
$controller = new CompteurController($dbConnection, $requestMethod, $id);
|
||||||
$controller->processRequest();
|
$controller->processRequest();
|
||||||
|
break;
|
||||||
|
case 'releve':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo json_encode($endpoints);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue