Hello,

You can either register precious resources in registry, e.g.:

protected function _initMyResource()
{
    $res = 'foobar';
    Zend_Registry::set('myResource', $res);
    return $res;
}

Or you can register whole bootstrap, so you can place in it's constructor,
something like this:

public function __construct($application)
{
    parent::contstruct($application);
    Zend_Registry::set('Bootstrap', $this);
}

So later you'll be able to access resources via:

$res = Zend_Registry::get('myResource');

or:

$res = Zend_Registry::get('Bootstrap')->getResource('MyResource');

And there is another way to get your bootstrapper from almost
everywhere:

$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$resource  = $bootstrap->getResource('MyResource');


2010/5/13 Sergio Rinaudo <kaiohken1...@hotmail.com>:
> Hi,
> I need to get a db resource from a controller plugin that extends
> Zend_Controller_Plugin_Abstract.
> In a controller context I'll do
>
>
>       $bootstrap = $this->getInvokeArg('bootstrap');
>       $resource = $bootstrap->getResource('myresource');
>
> but what if I want to get the resource in other context, for example,a
> plugin ?
> Maybe it's a dumb question, sorry about that :)
>
> Thanks in advance
>
> ________________________________
> Tanti account di posta? Unisci tutto sotto Hotmail



-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 617 179 344
Homepage: http://www.ixti.ru
JID: zappa...@jabber.ru

*Origin: Happy Hacking!

Reply via email to