2009-12-18 27 views
1

是否有幫助方法/對象/方法來獲取對Zend_Application的配置資源的引用?獲取對Zend_Application的配置對象的引用

我知道我可以這樣做

$config = new Zend_Config_Ini($file, $environment); 

但是這將重新加載/解析配置文件。我正在尋找一種方法來查看正在運行的Zend_Application的給定配置值。

我想解決的更大的問題是我想Zend_Queue使用相同的數據庫設置作爲我的默認數據庫資源。如果有更多的「Zend Like」方式來實現這一點,而不是「獲取引用配置,請閱讀資源值」,請隨時分享!

回答

3
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

有代碼Zend_Queue_Adapter_Db __construct if (isset($this->_options['dbAdapter'])),這樣你們可以做thomething這樣

new Zend_Queue_Adapter_Db(array('dbAdapter' => Zend_Db_Table::getDefaultAdapter())); 

因爲非標準Zend_Application_Resource_Db可以使用配置選項resources.db.isDefaultTableAdapter = true

或u可以把分貝在註冊表中的適配器,並從那裏得到它在任何地方

1
Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOptions() 
相關問題