Try this
Code:
// Write a variable into registry
public function registryInAction() {
//build your array
$value = array('index' => '123');
//unless your using more than 1 registry just use the default instance
$registry = Zend_Registry::getInstance();
//set your array in the Registry
Zend_Registry::set('test', $value);
//a better test
if($registry->isRegistered('test')) {
echo ' yoyo variable index has been registered!!<br />';
} else {
echo 'dizam sumphin wentz wrongz!';
}
//clear out $value
$value = null;
// get the index from registry
$value = Zend_Registry::get('test');
var_dump($value);
$this->_helper->viewRenderer->setNoRender();
}
Then this
Code:
// Try to read the value from registry
public function registryOutAction() {
// get the index from registry
$value = Zend_Registry::get('test');
var_dump( $value );
$this->_helper->viewRenderer->setNoRender();
}
I think you might have been confused about the difference between get()/set() and getInstance()/setInstance(). getInstance is basically a constructor for the singleton registry object. Meaning there is only one instance of the registry at any given time. You can create multiple instances but this is rarely needed. I have seen cases where the registry is setup, then destroyed and resetup, I"m not sure what's going on there...
Anyway, use set() and get() to store and retrieve variables, objects, arrays etc in the registry.
I didn't actually run the above code but it follows how I deal with the registry through out my app. Granted I did have some trouble with an array (see op) but I was confusing the registry for session data. See if this works and let me know the outcome.