Zend_Router requirements mismatch

Posted by elbicho on Stack Overflow See other posts from Stack Overflow or by elbicho
Published on 2009-10-08T12:12:18Z Indexed on 2010/05/17 5:10 UTC
Read the original article Hit count: 182

Filed under:

Hello you all:

I have two routes that match a url with the same apparent pattern, the difference lies in the $actionRoute, this should only be matched if the variable :action on it equals 'myaction'.

If I go to /en/mypage/whatever/myaction it goes as expected through $actionRoute.
If I go to /en/mypage/whatever/blahblah it gets rejected by $actionRoute and matched by $genRoute.
If I go to /en/mypage/whatever it should be matched by $genRoute but it gets matched by $actionRoute instead throwing and exception because the action noactionAction() does not exist.

Don't know what I'm doing wrong, I'd appreciate your help.

        $genRoute = new Zend_Controller_Router_Route(
   ':lang/mypage/:var1/:var2', 
   array(
    'lang'   => '',
    'module'  => 'mymodule',
    'controller' => 'index',
    'action'  => 'index',
    'var1'   => 'noone',
    'var2'   => 'no'
   ),
   array(
    'var1'   => '[a-z\-]+?',
    'lang'   => '(es|en|fr|de){1}'
   )
  );
  $actionRoute = new Zend_Controller_Router_Route(
   ':lang/mypage/:var1/:action', 
   array(
    'lang'   => '',
    'module'  => 'mymodule',
    'controller' => 'index',
    'action'  => 'noaction',
    'var1'   => 'noone',
   ),
   array(
    'action'  => '(myaction)+?',
    'var'   => '[a-z\-]+?',
    'lang'   => '(es|en|fr|de){1}',
   )
  );
  $router->addRoute('genroute',$genRoute);
  $router->addRoute('actionroute',$actionRoute);

© Stack Overflow or respective owner

Related posts about zend-framework