This would be really easy with a action helper (untested, but you get the idea):


class My_Controller_Action_Helper_Bootstrap extends 
Zend_Controller_Action_Helper_Abstract
{
   public function __get($name) {
      return 
$this->getActionController()->getInvokeArg('bootstrap')->getResource($name);
   }    
}

Then in your controller:

$acl = $this->_helper->bootstrap->acl;


Of course, I'd probably name it the Resource action helper, or somesuch.

On 26/05/2009 2:52 PM, swilhelm wrote:
I predict we will see this question every so often until the bootstrap
becomes more directly accessible, like the view.

So in a controller's action method, something like:

$this->bootstrap->db;

would be nice.

- Steve W.


Matthew Weier O'Phinney-3 wrote:
-- Vladas Diržys<[email protected]>  wrote
(on Tuesday, 26 May 2009, 09:40 PM +0300):
what is the right way to get a db (or any other) resource in the
controller?
Now I'm using following line:
$this->getFrontController()->getParam('bootstrap')->getResource('db');

Is there a better way?
Within your controller, yes, there's an easier way:

     $this->getInvokeArg('bootstrap')->getResource('db');

--
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/




Reply via email to