Getting a Reference to a Zend_Application's Config Object
Is there a helper method/object/methodology for getting a reference to a Zend_Application
's config resource?
I know I can do something like
$config = new Zend_Config_Ini($file, $environment);
but that's going to reload/parse the config file. I'm looking for a way to peek at the given configuration value for a running Zend_Application
.
The larger issue I'm trying to solve is I want a Zend_Queue
to use the same database settings as m开发者_如何转开发y default database resource. If there's a more "Zend Like" way of achieving this other than "get reference to config, read resource values" please feel free to share that as well!
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function run()
{
// make the config available to everyone
$config = $this->getOptions();
Zend_Registry::set('config', new Zend_Config($config));
parent::run();
}
}
Zend_Queue
there is code in Zend_Queue_Adapter_Db
__construct if (isset($this->_options['dbAdapter']))
so u can do thomething like this
new Zend_Queue_Adapter_Db(array('dbAdapter' => Zend_Db_Table::getDefaultAdapter()));
because standart Zend_Application_Resource_Db
can use config option resources.db.isDefaultTableAdapter = true
or u can put db adapter in registry and get it from there at any place
Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOptions()
精彩评论