Ejemplo n.º 1
0
 /**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  *根据ID删除设备
  * @param $deviceId
  * @return boolean
  */
 public function deleteDevice($deviceId)
 {
     //删除设备的Meta
     MiniUserDeviceMeta::getInstance()->deleteMeta($deviceId);
     //删除设备的Token
     MiniToken::getInstance()->deleteToken($deviceId);
     if ($this->hasCache === true) {
         //删除设备的cache
         $this->deleteCache($this->getCacheKey($deviceId));
     }
     //把在线设备清单进行删除
     MiniOnlineDevice::getInstance()->deleteOnlineDevice($deviceId);
     //把设备ID资源暂存到Options表中
     $this->temporary2Option($deviceId);
     //删除设备自己,这里不能修改为sql模式,因为设备ID在删除的时候,自动将ID记录到了Options表中
     $device = UserDevice::model()->findByPk($deviceId);
     if (isset($device)) {
         $device->delete();
     }
     return true;
 }