Changing interactions inside Router so it doesn't need a CakeRequest object, makes changes to Router test not necessary.

This commit is contained in:
Mark Story 2010-05-02 00:29:35 -04:00
parent 12cbf3198a
commit bd1365f8ae
2 changed files with 6 additions and 11 deletions

View file

@ -242,10 +242,11 @@ class Dispatcher extends Object {
extract($namedExpressions); extract($namedExpressions);
include CONFIGS . 'routes.php'; include CONFIGS . 'routes.php';
$request = Router::parse($request); $params = Router::parse($request->url);
$request->addParams($params);
if (!empty($additionalParams)) { if (!empty($additionalParams)) {
$request->params = array_merge($request->params, $additionalParams); $request->addParams($additionalParams);
} }
return $request; return $request;
} }

View file

@ -414,13 +414,12 @@ class Router {
} }
/** /**
* Parses given URL and returns an array of controller, action and parameters * Parses given URL string. Returns 'routing' parametets for that url.
* taken from that URL.
* *
* @param string $url URL to be parsed * @param string $url URL to be parsed
* @return array Parsed elements from URL * @return array Parsed elements from URL
*/ */
public static function parse($request) { public static function parse($url) {
$self =& Router::getInstance(); $self =& Router::getInstance();
if (!$self->__defaultsMapped && $self->__connectDefaults) { if (!$self->__defaultsMapped && $self->__connectDefaults) {
@ -433,9 +432,6 @@ class Router {
$r = $ext = null; $r = $ext = null;
// add a leading / and split out the query string.
// seems like this could be done in CakeRequest
$url = $request->url;
if ($url && strpos($url, '/') !== 0) { if ($url && strpos($url, '/') !== 0) {
$url = '/' . $url; $url = '/' . $url;
} }
@ -487,9 +483,7 @@ class Router {
if (!empty($ext) && !isset($out['url']['ext'])) { if (!empty($ext) && !isset($out['url']['ext'])) {
$out['url']['ext'] = $ext; $out['url']['ext'] = $ext;
} }
return $out;
$request->addParams($out);
return $request;
} }
/** /**