Yii::app()->getModule('user') 正在返回 'Trying to get property of non-object'

Yii::app()->getModule('user') is returning 'Trying to get property of non-object'

我有一个问题

Yii::app()->getModule('user') is not returning the right value view/layout/main.php

但我有一个不同的情况,我不能重新安装它,它是使用右扩展。 在主配置中

    'application.models.*',
    'application.components.*',
    'application.modules.rights.*',
    'application.modules.rights.components.*',



        'rights'=>array(
        'superuserName'=>'Admin', // Name of the role with super user privileges.
        'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
        'userIdColumn'=>'id', // Name of the user id column in the database.
        'userNameColumn'=>'username', // Name of the user name column in the database.
        'enableBizRule'=>true, // Whether to enable authorization item business rules.
        'enableBizRuleData'=>false, // Whether to enable data for business rules.
        'displayDescription'=>true, // Whether to use item description instead of name.
        'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
        'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
        'install'=>false, // Whether to enable installer.
        'debug'=>false, // Whether to enable debug mode. 
    ),

然后我需要更新此应用程序以使用用户扩展.. 我正在尝试,结果是:

 Trying to get property of non-object 


     <?php $this->widget('zii.widgets.CMenu',array(
         'items'=>array(
             array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),


<更新>
现在我得到了不同的错误:

Trying to get property of non-object 

public function tableName()
 {
     return Yii::app()->getModule('user')->tableUsers;
 }

在 \protected\modules\user\models\User.php(41)

我在主配置中的代码更新如下:

        'modules'=>array(
        'user'=>array(
            'tableUsers' => 'tbl_users',
            'tableProfiles' => 'tbl_profiles',
            'tableProfileFields' => 'tbl_profiles_fields',

知道我的错在哪里吗? *对不起,如果我语法不好。

SOLVED

在主配置中

    'rights'=>array(
        'superuserName'=>'Admin', // Name of the role with super user privileges.
        'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
        'userIdColumn'=>'id', // Name of the user id column in the database.
        'userNameColumn'=>'username', // Name of the user name column in the database.
        'enableBizRule'=>true, // Whether to enable authorization item business rules.
        'enableBizRuleData'=>false, // Whether to enable data for business rules.
        'displayDescription'=>true, // Whether to use item description instead of name.
        'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
        'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
        //'baseUrl'=>'/rights', // Base URL for Rights. Change if module is nested.
        //'layout'=>'rights.views.layouts.main', // Layout to use for displaying Rights.
        //'appLayout'=>'application.views.layouts.main', // Application layout.
        //'cssFile'=>'rights.css', // Style sheet file to use for Rights.
        'install'=>false, // Whether to enable installer.
        'debug'=>false, // Whether to enable debug mode. 
    ),
    'user'=>array(
        'hash' => 'md5',
        'tableUsers' => 'tbl_users',
        'tableProfiles' => 'tbl_profiles',
        'tableProfileFields' => 'tbl_profiles_fields',

并且不要更改模块中的任何内容.. 它的工作原理,就像魔术一样.. 哈哈