本文整理汇总了PHP中CWebUser::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP CWebUser::__get方法的具体用法?PHP CWebUser::__get怎么用?PHP CWebUser::__get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWebUser
的用法示例。
在下文中一共展示了CWebUser::__get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
/**
* @param string $attributeName
* @return mixed|null
*/
public function __get($attributeName)
{
assert('is_string($attributeName)');
assert('$attributeName != ""');
try {
if ($attributeName != 'isGuest' && ($this->userModel === null || $this->switched)) {
$username = parent::__get('username');
$this->userModel = User::getByUsername($username);
$this->switched = false;
}
if ($attributeName == 'userModel') {
return $this->userModel;
} elseif ($this->userModel !== null && $this->userModel->isAttribute($attributeName)) {
return $this->userModel->{$attributeName};
} else {
return parent::__get($attributeName);
}
} catch (NotFoundException $e) {
if (Yii::app()->isApplicationInstalled()) {
//Perhaps the username has changed, clear session and logout user.
Yii::app()->getSession()->destroy();
Yii::app()->request->redirect(Yii::app()->homeUrl);
}
} catch (CException $e) {
}
}
示例2: __get
public function __get($name)
{
if ($this->hasState('__userInfo')) {
$user = $this->getState('__userInfo', array());
if (isset($user[$name])) {
return $user[$name];
}
}
return parent::__get($name);
}
示例3: __get
public function __get($name)
{
if (array_key_exists($name, User::model()->relations())) {
if ($user = Yii::app()->getModule('user')->user($this->getId())) {
return $user->{$name};
}
return null;
}
return parent::__get($name);
}
示例4: __get
public function __get($attribute)
{
try {
return parent::__get($attribute);
} catch (CException $e) {
$model = $this->getModel();
if ($model) {
return $model->__get($attribute);
} else {
throw $e;
}
}
}
示例5: __get
public function __get($name)
{
try {
return parent::__get($name);
} catch (CException $e) {
$m = $this->getModel();
if ($m !== NULL && $m->hasAttribute($name)) {
return $m->{$name};
} else {
throw $e;
}
}
}
示例6: __get
public function __get($name)
{
try {
return parent::__get($name);
} catch (CException $e) {
$m = $this->getModel();
if ($m->__isset($name)) {
return $m->{$name};
} else {
throw $e;
}
}
}
示例7: __get
public function __get($name)
{
if ($this->hasState($name)) {
return $this->getState($name);
} elseif (in_array($name, $this->UserStatefulFields)) {
$user = $this->getUserModel();
if ($user) {
return $user->{$name};
} else {
return NULL;
}
} else {
return parent::__get($name);
}
}