History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-243
Type: Docs:  Improvement Docs: Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Nick Lo
Reporter: Michael Sheakoski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Custom route handlers for Zend_Controller_RewriteRouter

Created: 13/Jul/06 12:08 AM   Updated: 05/Jul/07 02:43 PM
Component/s: Zend_Controller
Affects Version/s: 0.1.5
Fix Version/s: 0.2.0

Time Tracking:
Not Specified

Tags:
Participants: Gavin, Michael Sheakoski, Michal Minicki and Nick Lo


 Description  « Hide
I am proposing a slight addition to Zend_Controller_RewriteRouter in order to have the ability to add custom route handlers without having to extend the RewriteRouter class
public function addCustomRoute($name, $routeHandler, $map, $params = array(), $reqs = array())
{
    if (!class_exists($routeHandler)) Zend::loadClass($routeHandler);
    $this->_routes[$name] = new $routeHandler($map, $params, $reqs);
}


Usage: (the % is just there to simulate someone's possible custom route)
$router = new Zend_Controller_RewriteRouter();
$router->addCustomRoute('myRoute', 'Custom_Controller_Router_MyRoute', '%controller/%action/%*{/}', array(), array());
$router->addRoute('news', 'news/:action', array(), array());


 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Michal Minicki - 14/Jul/06 07:42 AM
Made possible with changeset 914.

Michael Sheakoski - 14/Jul/06 01:08 PM
Martel that is very clever how you approached this! I didn't think to do it this way. Just in case anyone looks at this issue here is the new way to add custom routes:
$router->addRoute('archive', new Zend_Controller_Router_Route('archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+')));

Instead of the old way:

$router->addRoute('archive', 'archive/:year', array('year' => '2006', 'controller' => 'archive', 'action' => 'show'), array('year' => '\d+')); 

Gavin - 31/Aug/06 04:36 PM
The English manual should be updated to reflect this change.

http://framework.zend.com/manual/en/zend.controller.rewriterouter.html