-- Sergio Rinaudo <[email protected]> wrote
(on Thursday, 07 May 2009, 04:39 PM +0200):
> I reply to myself,
> I use to create a registry resource
>
>
>
> protected function _initRegistry(){
> $registry = Zend_Registry::getInstance();
> $config = new Zend_Config($this->getOptions());
> $registry->config = $config;
> return $registry;
> }
>
> then call
>
> $registry = $this->getResource('registry');
>
> where needed
> I also use to store config inside registry.
So, when you use getInstance(), you're getting a singleton instance of
Zend_Registry -- which means that you can use:
Zend_Registry::get('config')
anywhere.
If you want access to the _bootstrap's_ registry (which is what
getResource() accesses, and which is a unique, non-singleton, instance),
you can grab it from the front controller:
$registry =
Zend_Controller_Front::getInstance()->getParam('bootstrap')->getContainer();
>From your action controllers, it's actually simpler, as the front
controller parameters are passed as "invoke args" to the action
controller:
$registry = $this->getInvokeArg('bootstrap')->getContainer();
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/