/**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #2
0
 /**
  * web端入口,从session中获取用户
  */
 public function getUserFromSession()
 {
     $user = Yii::app()->session["user"];
     $deviceId = Yii::app()->session["deviceId"];
     if (empty($user) || empty($deviceId)) {
         return false;
     }
     // 获取web端设备id
     $device = MiniUserDevice2::getInstance()->getUserDevice2($deviceId);
     if ($device === NULL) {
         return false;
     }
     $userId = $user['id'];
     $userInfo = MiniUser2::getInstance()->getUser2($userId);
     $userInfo["appId"] = 1;
     $this->_current_user = $userInfo;
     $this->_current_device = $device;
     return $user;
 }