mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-01-17 12:18:16 +01:00
Merge pull request #3 from koenpunt/fix-indentation
fixed indentation on comment blocks
This commit is contained in:
commit
1fb2f87a57
@ -7,21 +7,22 @@ class AltoRouter {
|
||||
private $basePath = '';
|
||||
|
||||
/**
|
||||
* Set the base path.
|
||||
* Useful if you are running your application from a subdirectory.
|
||||
*/
|
||||
* Set the base path.
|
||||
* Useful if you are running your application from a subdirectory.
|
||||
*/
|
||||
public function setBasePath($basePath) {
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a route to a target
|
||||
*
|
||||
* @param string $method One of 4 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PUT|DELETE)
|
||||
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
||||
* @param mixed $target The target where this route should point to. Can be anything.
|
||||
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
||||
*
|
||||
*/
|
||||
* Map a route to a target
|
||||
*
|
||||
* @param string $method One of 4 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PUT|DELETE)
|
||||
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
||||
* @param mixed $target The target where this route should point to. Can be anything.
|
||||
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
||||
*
|
||||
*/
|
||||
public function map($method, $route, $target, $name = null) {
|
||||
|
||||
$route = $this->basePath . $route;
|
||||
@ -41,14 +42,14 @@ class AltoRouter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reversed routing
|
||||
*
|
||||
* Generate the URL for a named route. Replace regexes with supplied parameters
|
||||
*
|
||||
* @param string $routeName The name of the route.
|
||||
* @param array @params Associative array of parameters to replace placeholders with.
|
||||
* @return string The URL of the route with named parameters in place.
|
||||
*/
|
||||
* Reversed routing
|
||||
*
|
||||
* Generate the URL for a named route. Replace regexes with supplied parameters
|
||||
*
|
||||
* @param string $routeName The name of the route.
|
||||
* @param array @params Associative array of parameters to replace placeholders with.
|
||||
* @return string The URL of the route with named parameters in place.
|
||||
*/
|
||||
public function generate($routeName, array $params = array()) {
|
||||
|
||||
// Check if named route exists
|
||||
@ -83,11 +84,11 @@ class AltoRouter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a given Request Url against stored routes
|
||||
* @param string $requestUrl
|
||||
* @param string $requestMethod
|
||||
* @return array|boolean Array with route information on success, false on failure (no match).
|
||||
*/
|
||||
* Match a given Request Url against stored routes
|
||||
* @param string $requestUrl
|
||||
* @param string $requestMethod
|
||||
* @return array|boolean Array with route information on success, false on failure (no match).
|
||||
*/
|
||||
public function match($requestUrl = null, $requestMethod = null) {
|
||||
|
||||
$params = array();
|
||||
@ -183,8 +184,8 @@ class AltoRouter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the regex for a given route (EXPENSIVE)
|
||||
*/
|
||||
* Compile the regex for a given route (EXPENSIVE)
|
||||
*/
|
||||
private function compileRoute($route) {
|
||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user