Reputation: 1774
How can I call a module in another module? This code works on my Controllers in Protected/Controllers:
$image = Yii::app()->image->save($photofile, 'some_name','uploadedGal');
But in the controller of my other module (admin
) I get this error.
Property "CWebApplication.image" is not defined.
I have defined the image
module in my main config file:
'modules'=>array(
'image'=>array(
'createOnDemand'=>true, // requires apache mod_rewrite enabled
'install'=>true, // allows you to run the installer
),
'admin',
),
Upvotes: 1
Views: 6424
Reputation: 5202
You can import the module components in the config/main.php like below:
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.admin.models.*',
'application.modules.admin.components.*',
....
....
),
This way all models etc will be imported for you.
Upvotes: 2
Reputation: 1504
You need to include the other module components in your module class. Something like this:
class AdminModule extends CWebModule
{
public function init()
{
$this->setImport(array(
'admin.models.*',
'admin.components.*',
'image.models.*',
'image.components.*',
));
}
Upvotes: 7