1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-11 19:04:22 +02:00

added composer.json and newlines in end of files

This commit is contained in:
niahoo
2013-03-06 11:09:46 +01:00
parent ad87a4ae3a
commit fe4d390f0c
4 changed files with 29 additions and 10 deletions

View File

@@ -23,18 +23,18 @@ class AltoRouter {
*
*/
public function map($method, $route, $target, $name = null) {
$route = $this->basePath . $route;
$this->routes[] = array($method, $route, $target, $name);
if($name) {
if(isset($this->namedRoutes[$name])) {
throw new \Exception("Can not redeclare route '{$name}'");
if(isset($this->namedRoutes[$name])) {
throw new \Exception("Can not redeclare route '{$name}'");
} else {
$this->namedRoutes[$name] = $route;
}
}
return;
@@ -61,7 +61,7 @@ class AltoRouter {
$url = $route;
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
list($block, $pre, $type, $param, $optional) = $match;
@@ -75,7 +75,7 @@ class AltoRouter {
$url = str_replace($block, '', $url);
}
}
}
@@ -222,4 +222,4 @@ class AltoRouter {
}
return "`^$route$`";
}
}
}