2012-09-11 45 views

回答

2

它已經。在CWebModule中通過$ this-> setComponents如下:

<?php 

    class AccountModule extends CWebModule 
    { 
     public function init() 
     { 
      // this method is called when the module is being created 
      // you may place code here to customize the module or the application 

      $this->setComponents(array(
       'errorHandler' => array(
         'errorAction' => 'module/default/error'), 
       'defaultController' => 'default', 
       'user' => array(
         'class' => 'ModuleWebUser', 
         'allowAutoLogin'=>true, 
         'loginUrl' => Yii::app()->createUrl('module/default/login'), 
       ) 
      )); 

      // import the module-level models and components or any other components.. 
      $this->setImport(array(
       'module.models.*', 
       'module.components.*', 
      )); 
     } 
} ?> 
1

這樣做的方法是在main的params項中爲模塊/ etc創建一個數組項配置數組。

看這個論壇的帖子:http://www.yiiframework.com/forum/index.php/topic/24617-custom-configuration/

如果你希望你的配置是在一個單獨的文件,你可以在配置文件中的主配置陣列合併了! 這樣的事情應該工作:

include("custom_config.php"); // define $array_from_custom_conf inside this file 
return array_merge(
    array(/*main_config_array from main.php*/), 
    $array_from_custom_conf 
); 

如果你把你的自定義配置數組作爲第二個參數也將覆蓋從主配置屬性。

1

我從來沒有做過,但:

  • 電流解決方案在a wiki article提供。
  • 關於這個'功能要求',這已經在Yii的論壇上提出過了,這並不是什麼大驚喜。見herehere
相關問題