Created
April 6, 2010 14:34
-
-
Save stubbetje/357658 to your computer and use it in GitHub Desktop.
Gorilla_Controller_Action_Helper_Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Example_Controller extends Zend_Controller_Action | |
{ | |
public function indexAction() | |
{ | |
$db = $this->getHelper('resource')->db; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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