示例#1
0
function getABeacon(ParseObject $object)
{
    $beacon = new stdClass();
    $beacon->objectId = $object->getObjectId();
    $beacon->uuid = $object->get('UUID');
    $beacon->beaconColor = $object->get('beaconColor');
    if (count($object->getRelation("brand")->getQuery()->find()) != 0) {
        $beaconBrand = $object->getRelation("brand")->getQuery()->find();
        $beacon->brand = getABrand($beaconBrand[0]);
    } else {
        $beacon->brand = null;
    }
    $beacon->major = $object->get('major');
    $beacon->minor = $object->get('minor');
    $beacon->name = $object->get('name');
    if ($object->get('region') != null) {
        $beaconRegion = $object->get('region')->fetch();
        $beacon->region = getARegion($beaconRegion);
    } else {
        $beacon->region = null;
    }
    $beacon->type = $object->get('type');
    $beacon->createdAt = $object->getCreatedAt();
    $beacon->upadtedAt = $object->getUpdatedAt();
    return $beacon;
}
示例#2
0
 /**
  * Merge data from other object.
  *
  * @param ParseObject $other
  */
 private function mergeFromObject($other)
 {
     if (!$other) {
         return;
     }
     $this->objectId = $other->getObjectId();
     $this->createdAt = $other->getCreatedAt();
     $this->updatedAt = $other->getUpdatedAt();
     $this->serverData = $other->serverData;
     $this->operationSet = [];
     $this->hasBeenFetched = true;
     $this->rebuildEstimatedData();
 }
示例#3
0
 /**
  * @return array
  */
 public function parseObjectToArray(ParseObject $object)
 {
     $array = $object->getAllKeys();
     $array['objectId'] = $object->getObjectId();
     $createdAt = $object->getCreatedAt();
     if ($createdAt) {
         $array['createdAt'] = $this->dateToString($createdAt);
     }
     $updatedAt = $object->getUpdatedAt();
     if ($updatedAt) {
         $array['updatedAt'] = $this->dateToString($updatedAt);
     }
     if ($object->getACL()) {
         $array['ACL'] = $object->getACL()->_encode();
     }
     foreach ($array as $key => $value) {
         if ($value instanceof ParseObject) {
             if ($value->getClassName() == $this->parseObject->getClassName() && $value->getObjectId() == $this->parseObject->getObjectId()) {
                 // If a key points to this parent object, we will skip it to avoid
                 // infinite recursion.
             } elseif ($value->isDataAvailable()) {
                 $array[$key] = $this->parseObjectToArray($value);
             }
         } elseif ($value instanceof ParseFile) {
             $array[$key] = $value->_encode();
         }
     }
     return $array;
 }