Exemplo n.º 1
0
 /**
  * @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) {
     }
 }
Exemplo n.º 2
0
 public function __get($name)
 {
     if ($this->hasState('__userInfo')) {
         $user = $this->getState('__userInfo', array());
         if (isset($user[$name])) {
             return $user[$name];
         }
     }
     return parent::__get($name);
 }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
 public function __get($attribute)
 {
     try {
         return parent::__get($attribute);
     } catch (CException $e) {
         $model = $this->getModel();
         if ($model) {
             return $model->__get($attribute);
         } else {
             throw $e;
         }
     }
 }
Exemplo n.º 5
0
 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;
         }
     }
 }
Exemplo n.º 6
0
 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;
         }
     }
 }
Exemplo n.º 7
0
 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);
     }
 }