如何在另一个模块中调用模块?此代码适用于受保护/控制器中的控制器:
$image = Yii::app()->image->save($photofile, 'some_name','uploadedGal');
Run Code Online (Sandbox Code Playgroud)
但在我的其他模块(admin)的控制器中,我得到了这个错误.
Property "CWebApplication.image" is not defined.
Run Code Online (Sandbox Code Playgroud)
我image在主配置文件中定义了模块:
'modules'=>array(
'image'=>array(
'createOnDemand'=>true, // requires apache mod_rewrite enabled
'install'=>true, // allows you to run the installer
),
'admin',
),
Run Code Online (Sandbox Code Playgroud)
您需要在模块类中包含其他模块组件.像这样的东西:
class AdminModule extends CWebModule
{
public function init()
{
$this->setImport(array(
'admin.models.*',
'admin.components.*',
'image.models.*',
'image.components.*',
));
}
Run Code Online (Sandbox Code Playgroud)