5

モジュール内のmain.confを拡張する構成ファイルを追加できるかどうかを知りたいだけです

4

3 に答える 3

2

すでにそうです。次のように$this->setComponentsを介してCWebModuleで:

<?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.*',
            ));
        }
} ?>
于 2013-02-24T22:16:48.300 に答える
1

これを行う方法は、メイン構成配列のparams項目にモジュールなどの配列項目を作成することです。

このフォーラムの投稿を見てください: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
);

カスタム構成配列を2番目の引数として指定すると、メイン構成の属性も上書きされます。

于 2012-09-11T08:21:23.563 に答える
1

私はそれをしたことがありませんが:

  • 現在の解決策は、wikiの記事で提供されています。
  • この「機能リクエスト」に関して、これがYiiのフォーラムですでにリクエストされていることは大きな驚きではありません。ここここを参照してください。
于 2012-09-11T08:58:17.650 に答える