Module's init()

Hi!

I've generated new module and noticed new nice approach

$this->setImport(array(


            'client.models.*',


            'client.components.*',


        ));


It's nice that I'm not required to modify config several times, only enable module. But I've spotted problem with this:

I've founded that modules init() method called only if I'm requesting that module's controller. But if I need model from that module and page is generating with another module's controller I've got class not found exception.

So, how should I deal with it? I would like to use that setImport in modules init and not add import into configs?

Thank you in advance

up

You will need to use Yii::app()->getModule($name) to generate the module instance first so that its init() can be executed.

Since you are sharing models among modules, it would better if you move those models to the application folder.