Adding _METHOD support to routing

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1210 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-02-27 15:36:49 +00:00
parent 6ce3776d12
commit a50e28dc16
2 changed files with 24 additions and 6 deletions

View File

@@ -137,7 +137,8 @@ class route
- search can be the end of URL and optionnal parameters in {var1} format
{var1} must be the name of the parameter of the method
- action is an array with (0=>CLASS, 1=>method, 2...=>parameters) */
function routingCollection ($routes)
// DISABLED FUNCTION : TOO COMPLEX !!
/*function routingCollection ($routes)
{
if ($this->debug)
echo "<pre>==== DEBUG : ROUTING START ====\n";
@@ -251,7 +252,7 @@ class route
echo "URL='";print_r ($url); echo "'\n";
echo "ROUTE='";print_r ($route); echo "'\n";
}*/
/*
// URL === ROUTE (No variables)
if ($url === $route)
@@ -388,12 +389,23 @@ class route
// TODO : ERROR 404 !
echo "404";
return;
}
}*/
/** Return the HTTP method used to connect to the page
Can be override by a _METHOD parameter provided in POST
Throw an exception in case of error */
public function method ()
{
if (isset ($_POST["_METHOD"]) &&
($_POST["_METHOD"] === "GET" ||
$_POST["_METHOD"] === "POST" ||
$_POST["_METHOD"] === "PUT" ||
$_POST["_METHOD"] === "DELETE"))
{
$this->method = $_POST["_METHOD"];
return $_POST["_METHOD"];
}
if (!isset ($_SERVER["REQUEST_METHOD"]))
throw new Exception ("No REQUEST_METHOD", 415);
if ($_SERVER["REQUEST_METHOD"] === "GET" ||
@@ -474,7 +486,7 @@ class route
{
if ($this->debug)
echo "<pre>==> DELETE $route ?? ";
if ($this->method () !== " DELETE")
if ($this->method () !== "DELETE")
{
if ($this->debug)
echo "==> Not a DELETE Method\n";