Using Bootstrap
Add this to your Boostra.php file:
This file contains hidden or 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 Bootstrap extends Zend_Application_Bootstrap_Bootstrap { | |
//... | |
protected function _initConfig(){ | |
$config_options = new Zend_Config($this->getOptions()); | |
Zend_Registry::set('config', $config_options); | |
return $config_options; | |
} | |
} |
You can fetch the config wherever you want using:
$config = Zend_Registry::get("config");Loading from Front controller
From a View action:
This file contains hidden or 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 MyController extends Zend_Controller_Action { | |
//... | |
public function myAction(){ | |
$bootstrap = $this->getInvokeArg('bootstrap'); | |
$config_options = $bootstrap->getOptions(); | |
} | |
} |
From outside the controller:
This file contains hidden or 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 | |
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); | |
$config_options = $bootstrap->getOptions(); |
No hay comentarios.:
Publicar un comentario