2009年2月25日星期三

Re: [fw-mvc] passing parameters to the action controller

Do you get the param by calling $this->getInvokeArgs() in the controller?

You could use Zend_Registry::set() and Zend_Registry::get() to pass your params.

On Feb 25, 2009, at 3:26 PM, Seth Atkins wrote:

I'm trying to find the proper way of passing objects or parameters from the front controller to the action controller. I've read the documentation, so please skip the RTFM stuff... :-). In the docs it says this:
 
10.3.4
 In the introduction, we indicated that the front controller also acts as a registry for the various controller components. It does so through a family of "param" methods. These methods allow you to register arbitrary data -- objects and variables -- with the front controller to be retrieved at any time in the dispatch chain. These values are passed on to the router, dispatcher, and action controllers. The methods include:
 
So as I read this, if in the bootstrap script I do this:
 
$front->setParam('foo', 'bar');
 
then parameter 'foo' should have value 'bar' within the action controller. However, in the action method of my action controller, lets say, MyactionController this statement only shows three parameters, not the one I just set.
 
$this->_getAllParams();
 
What I get returned from that is three parameters for action, controller, and module. foo => bar isn't there. Maybe I'm misreading the documentation, but it says "arbitrary data", and that those values are passed to the action controller. Am I barking up the wrong tree, or did I miss something?
 

Seth


Shawn Ostler
InclusiveDv



没有评论: