2009年11月14日星期六

[fw-mvc] Chaining Hostname and REST Routes

Has anyone successfully chained together a Hostname and a REST route?
My REST route works fine on its own, but dispatching breaks once I
chain it together with a hostname route. Here's a stripped down
example that I would think should work:

// I'm obviously not using example.com, but I *have*
double-checked the domain
// The reason for this route is that I'm going to use the
scheme parameter and set it to https
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
'example.com'
);
// If I were to *only* add this route, not chained with the
hostname route, everything would work fine
// Note that I'm only adding the REST route for the checkout
module, in case that's relevant
$restRoute = new Zend_Rest_Route(
$this->_front,
array(),
array(
'checkout'
)
);
// I've tried chaining each route to the other instead of using a chain
$chainedRoute = new Zend_Controller_Router_Route_Chain();
$chainedRoute
->chain($hostnameRoute)
->chain($restRoute)
;
// For now I'm not changing the route name so existing code
doesn't break
$router->addRoute(
'rest',
$chainedRoute
);

Then, upon requesting:

http://example.com/checkout/order/some-id

and examining my request in the preDispatch of a controller plugin I
see the following, incorrect, parameters:

'module' => string 'checkout'
'controller' => string 'order'
'action' => string 'some-id'

The parameters I would expect are:

'module' => string 'checkout'
'controller' => string 'order'
'action' => string 'get'
'id' => string 'some-id'

Am I doing something wrong or is chaining Hostname and REST routes
together not supported?

Thanks,
Bradley

--
Bradley Holt
bradley.holt@foundline.com

没有评论: