Commit 92fd58c0 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

use default route when assembling

parent 69d542e4
......@@ -77,20 +77,20 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
/**
* Add route to the route chain
*
*
* If route implements Zend_Controller_Request_Aware interface it is initialized with a request object
*
* @param string $name Name of the route
* @param Zend_Controller_Router_Route_Interface Route
*/
public function addRoute($name, Zend_Controller_Router_Route_Interface $route)
public function addRoute($name, Zend_Controller_Router_Route_Interface $route)
{
if (method_exists($route, 'setRequest')) {
$route->setRequest($this->getFrontController()->getRequest());
}
$this->_routes[$name] = $route;
return $this;
}
......@@ -138,7 +138,7 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
}
$config = $config->{$section};
}
foreach ($config as $name => $info) {
$class = (isset($info->type)) ? $info->type : 'Zend_Controller_Router_Route';
......@@ -264,14 +264,14 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
/** Find the matching route */
foreach (array_reverse($this->_routes) as $name => $route) {
// TODO: Should be an interface method. Hack for 1.0 BC
// TODO: Should be an interface method. Hack for 1.0 BC
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $request->getPathInfo();
} else {
$match = $request;
}
if ($params = $route->match($match)) {
$this->_setRequestParams($request, $params);
$this->_currentRoute = $name;
......@@ -304,24 +304,28 @@ class Zend_Controller_Router_Rewrite extends Zend_Controller_Router_Abstract
/**
* Generates a URL path that can be used in URL creation, redirection, etc.
*
*
* @param array $userParams Options passed by a user used to override parameters
* @param mixed $name The name of a Route to use
* @param bool $reset Whether to reset to the route defaults ignoring URL params
* @param bool $encode Tells to encode URL parts on output
* @throws Zend_Controller_Router_Exception
* @return string Resulting absolute URL path
*/
*/
public function assemble($userParams, $name = null, $reset = false, $encode = true)
{
if ($name == null) {
try {
$name = $this->getCurrentRouteName();
} catch (Zend_Controller_Router_Exception $e) {
$name = 'default';
if ($this->_useDefaultRoutes) {
$this->addDefaultRoutes();
}
$name = 'default';
}
}
$route = $this->getRoute($name);
$url = $route->assemble($userParams, $reset, $encode);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment