route : add the 'multi' method to allow multiple methods to be applied to the same route and function
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2225 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
16
route.php
16
route.php
@@ -344,6 +344,22 @@ class route
|
|||||||
return $this->map ($route, $function);
|
return $this->map ($route, $function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Allow multiple methods to execute the function if the route is
|
||||||
|
corresponding to the URL.
|
||||||
|
Ex. : $app->multi("get,post,put,delete", '/hello/{name}', function ($name) {
|
||||||
|
echo "Hello, $name";
|
||||||
|
});
|
||||||
|
@param string $methods The allowed methods, separated by commas (,)
|
||||||
|
@param string $route Route to check with the URL
|
||||||
|
@param function $function Function to be executed if the route match */
|
||||||
|
public function multi ($methods, $route, $function)
|
||||||
|
{
|
||||||
|
foreach (explode (",", $methods) as $method)
|
||||||
|
{
|
||||||
|
$this->$method ($route, $function);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Do the mapping between the url and the route : call the function if
|
/** Do the mapping between the url and the route : call the function if
|
||||||
thereis a match
|
thereis a match
|
||||||
@param string $route Route to check with the URL
|
@param string $route Route to check with the URL
|
||||||
|
|||||||
Reference in New Issue
Block a user