(on Thursday, 21 October 2010, 12:49 PM -0400):
> I've been trying to pass an array from one Controller to another
> without any luck. I've tried to use the Zend_Registry, but when I try
> to retrieve the value in the next Controller, I get an error "No entry
> is registered for key 'resultsAdmin'". So how is this done without
> resorting to redirects and such? I've tried using
> Zend_Session_Namespace(), but can't find any answers as to how to
> retrieve the value from the Namespace() once it is set. There has to
> be a way to create a globalized variable and access it, but how is it
> done in Zend?
What do you mean by "one controller to another", exactly?
* Are you using _forward() or the ActionStack, and trying to pass data
from one controller to the next using one of these?
* Or are you talking about passing data between requests?
The answers will be different based on how you answer those questions.
In the case of the first, _forward() accepts an array of parameters to
pass as the fourth argument (_forward($action, $controller, $module,
$params)). ActionStack requires you to either update your request object
and pass it (or create a new one and pass that), or use the
actionToStack() method, which has the same signature as _forward().
In the case of the second, you'll need to pass the data using the
session. Zend_Session_Namespace is quite easy:
// Setting the data:
$namespace = new Zend_Session_Namespace('someaction');
$namespace->data = $arrayOfData;
// Retrieving the data:
$namespace = new Zend_Session_Namespace('someaction');
$data = $namespace->data;
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
没有评论:
发表评论