2008年12月5日星期五

Re: [fw-mvc] Re[fw-mvc] dundant action parameters in request object?

-- Marc Grue <marc@grue.info> wrote
(on Friday, 05 December 2008, 11:01 AM -0800):
> Why is $this->_forward in a controller not causing the
> $request->_params to update too?

Let's turn the question around: why should it?

<snip>

> Is there a reason to have a disambigous Request object after a
> forward, or should I use another approach?

Well, there are plenty of reasons: different actions may be able to
operate on the same sets of input, you may need to keep a history of
some of the changes, etc.

> Why do you (Zend_Controller_Router_Rewrite->route ...
> _setRequestParams) want to save the action params both in
> $request->_params and the protected Request vars
> ($request->_controller etc)?

Actually, it doesn't -- it only saves them in the _params array. The
accessors for the specific required elements -- getActionName,
getControllerName, getModuleName -- actually proxy to the _params array
if the protected members they refer to are not present. This makes for a
simpler usage in the router, while also allowing for discrete setting of
the values separate from parameters (useful during testing).

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: