(on Friday, 14 August 2009, 02:50 PM -0400):
> I've setup the following REST Route for my "checkout" module:
>
> $router->addRoute(
> 'rest',
> new Zend_Rest_Route(
> $this->_front,
> array(),
> array(
> 'checkout'
> )
> )
> );
>
> I've also implemented the following five methods from
> Zend_Rest_Controller in my Checkout_ShippingController:
>
> * indexAction()
> * getAction()
> * postAction()
> * putAction()
> * deleteAction()
>
> I would expect that by navigating to checkout/shipping I would be
> routed to Checkout_ShippingController::indexAction(). However, I'm
> actually routed to Checkout_ShippingController::listAction() which I
> had not implemented yet since it was not defined as an abstract method
> in Zend_Rest_Controller (therefore getting an error). Is this by
> design or is there a mismatch between Zend_Rest_Route and
> Zend_Rest_Controller Mismatch? I suspect that either
> Zend_Rest_Controller::indexAction is supposed to be named
> Zend_Rest_Controller::listAction or that the default action for
> Zend_Rest_Route should be "index" instead of "list". Of course I can
> work around this by simply implementing an empty indexAction and
> implement my own listAction, but this seems like an odd thing to have
> to do (ignoring an abstract method I'm forced to implement and then
> needing to implement a method that is not defined in the abstract
> class in order to get the routing to work correctly).
There are one or two issues in the tracker about this already, and I
could have sworn I'd fixed it for 1.9.1 - but clearly I hadn't.
For now, in your controllers extending Zend_Rest_Controller, define a
listAction() method, and have it _forward() to indexAction() (which is
what the proposal defined); I'll update Zend_Rest_Route this week, and
it will be reflected in 1.9.2.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论