[TASK] Changes

- Added support for alias on RouterRoute.
- Added typo in resource (renamed class from Ressource to Resource).
- Added optional settings parameter in most of the methods in the
  SimpleRouter class.
This commit is contained in:
Simon Sessingø
2015-10-21 00:27:47 +02:00
parent 7863df6325
commit 626a3b2f6a
5 changed files with 216 additions and 39 deletions
+9 -4
View File
@@ -167,11 +167,11 @@ class RouterBase {
$url = $route->getUrl();
if(($route instanceof RouterController || $route instanceof RouterRessource) && $method !== null) {
if(($route instanceof RouterController || $route instanceof RouterResource) && $method !== null) {
$url .= $method;
}
if($route instanceof RouterController || $route instanceof RouterRessource) {
if($route instanceof RouterController || $route instanceof RouterResource) {
if(count($parameters)) {
$url .= join('/', $parameters);
}
@@ -217,9 +217,14 @@ class RouterBase {
/* @var $route RouterRoute */
foreach($this->controllerUrlMap as $route) {
// Check an alias exist, if the matches - use it
if($route instanceof RouterRoute && strtolower($route->getAlias()) === strtolower($controller)) {
return $this->processUrl($route, $route->getMethod(), $parameters, $getParams);
}
if($route instanceof RouterRoute && !is_callable($route->getCallback()) && stripos($route->getCallback(), '@') !== false) {
$c = $route->getCallback();
} else if($route instanceof RouterController || $route instanceof RouterRessource) {
} else if($route instanceof RouterController || $route instanceof RouterResource) {
$c = $route->getController();
}
@@ -234,7 +239,7 @@ class RouterBase {
foreach($this->controllerUrlMap as $route) {
if($route instanceof RouterRoute && !is_callable($route->getCallback()) && stripos($route->getCallback(), '@') !== false) {
$c = $route->getClass();
} else if($route instanceof RouterController || $route instanceof RouterRessource) {
} else if($route instanceof RouterController || $route instanceof RouterResource) {
$c = $route->getController();
}