ZF-7575: Variable Defaults in Zend_Controller_Router_Route

Description


Zend_Controller_Router_Route(
  ':lang/:controller/:pageid/*', 
  array('controller' => 'index'), 
  array('lang' => 'fr|nl|en')
);

will not match a URL like "/fr/services-webmaster "

Though, tI expected ":controller" getting the default value "index" as specified and ":pageid" getting "services-webmaster" from the URL. But instead the next router will be cjecked for a match.

It's in contradiction with the documentation:


The following route more-or-less mimics the Module route behavior:


$route = new Zend_Controller_Router_Route(
    ':module/:controller/:action/*',
    array('module' => 'default')
);
$router->addRoute('default', $route);

As you know, the way the default ZF route works doesn't oblige you to specify a module, the same way goes for my code (for the ":controller" part) above which doesn't work.

Also, if the default params aren't working, and I consider that :lang, :module and :controller are optional in my example above, I'll have to define a bunch of routes:



$route = new Zend_Controller_Router_Route(
    ':module/:controller/:pageid/*', 
    array(), 
    array('lang' => 'fr|nl|en', 'module' => 'admin|default|test|members')
);
$router->addRoute('default4', $route);

$route = new Zend_Controller_Router_Route(
    ':controller/:pageid/*', 
    array(), 
    array('lang' => 'fr|nl|en')
);
$router->addRoute('default5', $route);

$route = new Zend_Controller_Router_Route(
    ':lang/:module/:controller/:pageid/*', 
    array(), 
    array('lang' => 'fr|nl|en', 'module' => 'admin|default|test|members')
);
$router->addRoute('default6', $route);

$route = new Zend_Controller_Router_Route(
    ':lang/:controller/:pageid/*', 
    array('controller' => 'index'), 
    array('lang' => 'fr|nl|en')
);
$router->addRoute('default7', $route);

$route = new Zend_Controller_Router_Route(
    ':pageid'
);
$router->addRoute('default8', $route);

$route = new Zend_Controller_Router_Route(
    ':lang/:pageid/*', 
    array(), 
    array('lang' => 'fr|nl|en')
);
$router->addRoute('default9', $route);

Again, if the second param was working as expected from the doc, I would only have to define:


$route = new Zend_Controller_Router_Route(
    ':lang/:module/:controller/:pageid/*', 
    array('lang' => 'fr', 'module' => 'default', 'controller' => 'index'), 
    array('lang' => 'fr|nl|en')
);
$router->addRoute('default2', $route);

Comments

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.