Skip to content

Instantly share code, notes, and snippets.

@stubbetje
Created April 6, 2010 14:34
Show Gist options
  • Save stubbetje/357658 to your computer and use it in GitHub Desktop.
Save stubbetje/357658 to your computer and use it in GitHub Desktop.
Gorilla_Controller_Action_Helper_Resource
<?php
class Example_Controller extends Zend_Controller_Action
{
public function indexAction()
{
$db = $this->getHelper('resource')->db;
}
}
<?php
class Gorilla_Controller_Action_Helper_Resource extends Zend_Controller_Action_Helper_Abstract
{
/**
* @var Zend_Application_Bootstrap_Bootstrap
*/
protected $_bootstrap = null;
/**
* get application bootstrap
*
* @return Zend_Application_Bootstrap_Bootstrap
*/
public function getBootstrap()
{
if( null === $this->_bootstrap ) {
$this->_bootstrap = $this->getFrontController()->getParam( 'bootstrap' );
}
return $this->_bootstrap;
}
/**
* set bootstrap
*
* @param $bootstrap Zend_Application_Bootstrap_Bootstrap
* @return Gorilla_Controller_Action_Helper_Resource
*/
public function setBootstrap( Zend_Application_Bootstrap_Bootstrap $bootstrap )
{
$this->_bootstrap = $bootstrap;
return $this;
}
public function __get( $name )
{
$bootstrap = $this->getBootstrap();
/* if( ! $bootstrap->hasResource( $name ) ) {
throw new Exception( )
}
*/
return $bootstrap->getResource( $name );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment