Issues

ZF-7575: Variable Defaults in Zend_Controller_Router_Route

Issue Type: Bug Created: 2009-08-12T15:13:33.000+0000 Last Updated: 2012-11-20T20:52:32.000+0000 Status: Closed Fix version(s): Reporter: Mathieu Decaffmeyer (mathi) Assignee: None Tags: - Zend_Controller

Related issues: Attachments:

Description

<pre class="highlight">
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:

<pre class="highlight">
$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:


<pre class="highlight">
$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:

<pre class="highlight">
$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

Posted by Rob Allen (rob) on 2012-11-20T20:52:32.000+0000

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.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts