Shorten Zend Framework Route Definitions
Posted
by Sebastian Hoitz
on Stack Overflow
See other posts from Stack Overflow
or by Sebastian Hoitz
Published on 2009-04-27T15:46:32Z
Indexed on
2010/06/03
19:54 UTC
Read the original article
Hit count: 416
Hi! How can I shorten the definition of my custom routes in Zend Framework? I currently have this as definition:
$route = new Zend_Controller_Router_Route(
":module/:id",
array(
"controller" => "index",
"action" => "index"
),
array("id" => "\d+")
);
self::$frontController->getRouter()->addRoute('shortcutOne', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:id",
array("action" => "index"),
array("id" => "\d+")
);
self::$frontController->getRouter()->addRoute('shortcutTwo', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:action/:id",
null,
array("id" => "\d+")
);
self::$frontController->getRouter()->addRoute('shortcutThree', $route);
Is there a way to better combine these rules? And what are your best practices in where to place these? I currently have them in my bootstrap class right after the Front Controller initialization.
© Stack Overflow or respective owner