Search code examples
phpyii

Can a module have its own config file?


I just want to know if we can add a config file that extends the main.conf in the module


Solution

  • It does, already. in the CWebModule through $this->setComponents as follows:

    <?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.*',
                ));
            }
    } ?>