Reputation: 1435
cwebuser.isShop is not defined when a function exists. Not understanding why. I've searched around and all i find is the same question, no answer? What I am trying to do is to login from a module name shop but I get not defined. What else am I missing?
in my main module;
public function beforeControllerAction($controller, $action)
{
if(Yii::app()->getModule('shop')->user->isShop)
Yii::app()->getModule('shop')->user->setReturnUrl('shop/default/login');
else
return false;
}
In webuser:
function isShop(){
if (!isset(Yii::app()->user->user))
return false;
$user = Yii::app()->user->user;
return intval($user->user_role_id) == 2;
}
Upvotes: 1
Views: 125
Reputation: 247
If you write
Yii::app()->getModule('shop')->user->isShop
you are trying to access a variable of the Object user called isShop
. Two cases:
isShop
is a variable isShop
is a Virtual variableYours is the second case. This means that isShop
is the result of calling the function getIsShop
of the Object user, but your function is named only isShop
.
Two Solutions:
isShop
to getIsShop
Yii::app()->getModule('shop')->user->isShop()
. [see the round brackets]
Upvotes: 2