2013-07-12 68 views
1

我试图从模块中引入yii引导程序。我想保留在/ modules/myModule/extensions/bootstrap和主配置之外的所有配置参数。可能吗?模块内部的Yii引导程序

目前Mymodule中的init我做

$this->setImport(array(
'myModule.models.*', 
'myModule.components.*', 
'myModule.extensions.yiistrap.helpers.TbHtml', 
'myModule.extensions.bootstrap.components.*', 
'myModule.extensions.bootstrap.widgets.*' 
)); 


if (!Yii::app()->hasComponent('bootstrap')) { 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . '/extensions/bootstrap'); 
Yii::createComponent('bootstrap.components.Bootstrap')->init(); 
Yii::app()->bootstrap->register(); 
} 
} 

,它适用于一些小部件,但最让我得到错误

Property "CWebApplication.bootstrap" is not defined. 

回答

0

您需要设置应用程序的引导组件,这应该工作:

Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . '/extensions/bootstrap'); 
$bootstrap = Yii::createComponent('bootstrap.components.Bootstrap'); 
$bootstrap->init(); 
Yii::app()->bootstrap = $bootstrap; 
$bootstrap->register(); 

将配置传递到引导程序:

$config = array(
    'class' => 'bootstrap.components.Bootstrap', 
    'option1' => ... 
); 
$bootstrap = Yii::createComponent($config); 
相关问题