Yii, Load a model of a module from the main app controller

634 views Asked by At

I would like to load a model in booksImported module from main app controller,

main.php

    'import'=>array(
    'application.models.*',
    'application.components.*',
            'application.modules.booksCategory.models.*', 
            'application.modules.booksImported.models.*' 
         ),

In my SiteController function i tried..

Yii::app()->getModule('Importedbooks')

This only gets the Module name. I also tried

       Yii::setPathOfAlias('booksImported','../modules/booksImported/models');

        Yii::import('booksImported.models.Importedbooks',true);  // this will include the class DesiredModel immediately

        $model = Yii::createComponent('Importedbooks');

        print_r($model);

which gives an error

Alias "booksImported.models.Importedbooks" is invalid. Make sure it points to an existing PHP file and the file is readable.
0

There are 0 answers