|
|||
|
Hi,
I created a class "Page" , save it in the lib folder. <?php class Page{ var $name = null; } I load it into my bootstrap file-index.php, then create an object $myPage = new Page(); $myPage->name = "BOOTSTRAP"; then I registered it: Zend::register('myPage',$myPage); In my indexAction controller, I access the object: function indexAction(){ $myPage = Zend::registry('myPage'); $myPage->name = "INDEX ACTION"; echo $myPage->name; } and in my listAction controller, I access the same object: function listAction(){ $myPage = Zend::registry('myPage'); echo $myPage->name; } Now, when I run the page, First page I got message "INDEX ACTION", good. But, when I open Index/List , I got message "BOOTSTRAP"... I was expecting to get a message "INDEX ACTION".. So, it seems that when I execute Index/List, myPage object is re-created again in the bootstrap file, so the value back to the first. My question is, how can I make myPage not be re-created when I execute Index/List ? Thanks! |
|
|||
|
with the registry, the object is copied, not passed by reference if I remember. This is to prevent the application from modifying the object and causing problems. The zend registry does not allow you to modify a registered object, but I think in the new release this 'feature' has been removed. So you would have to reregister the object.
I wouldnt quote myself on this as I have not used the registry much as I try to avoid it because using getInvokeArg() seems to be a better option when using the zend frontcontroller |
![]() |
| Thread Tools | |
| Display Modes | |
|
|