Skip to content

Commit

Permalink
Merge branch 'feature/router-to-use-keyvalstore' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
trq committed Apr 8, 2012
2 parents 0f912f9 + e808c54 commit c1a4a45
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/Proem/Api/Routing/Router/Standard.php
Expand Up @@ -33,7 +33,8 @@
use Proem\Routing\Router\Template,
Proem\Routing\Route\Template as Route,
Proem\Routing\Signal\Event\RouteMatch,
Proem\Signal\Manager\Template as SignalManager;
Proem\Signal\Manager\Template as SignalManager,
Proem\Util\Storage\KeyValStore;

/**
* Proem\Api\Routing\Router\Standard
Expand All @@ -48,9 +49,9 @@ class Standard implements Template
/**
* Store our routes
*
* @var array
* @var Proem\Util\Storage\KeyValStore
*/
private $routes = [];
private $routes;

/**
* Setup
Expand All @@ -60,14 +61,15 @@ class Standard implements Template
public function __construct($requestUrl)
{
$this->requestUrl = $requestUrl;
$this->routes = new KeyValStore;
}

/**
* Store route objects
*/
public function map($name, Route $route)
{
$this->routes[$name] = $route;
$this->routes->set($name, $route);
return $this;
}

Expand All @@ -84,8 +86,8 @@ public function map($name, Route $route)
*/
public function route()
{
if ($route = current($this->routes)) {
next($this->routes);
if ($route = $this->routes->current()) {
$this->routes->next();
$route->process($this->requestUrl);

if ($route->isMatch() && $route->getPayload()->isPopulated()) {
Expand All @@ -94,7 +96,7 @@ public function route()
return $this->route();
}
}
reset($this->routes);
$this->routes->rewind();
return false;
}
}

0 comments on commit c1a4a45

Please sign in to comment.