Esempio n. 1
0
 public function save($useMasterKey = false)
 {
     if (!$this->getACL()) {
         throw new ParseException("Roles must have an ACL.");
     }
     if (!$this->getName() || !is_string($this->getName())) {
         throw new ParseException("Roles must have a name.");
     }
     return parent::save($useMasterKey);
 }
Esempio n. 2
0
 /**
  * Save the current user object, unless it is not signed up.
  *
  * @throws ParseException
  *
  * @return null
  */
 public function save($useMasterKey = false)
 {
     if ($this->getObjectId()) {
         parent::save($useMasterKey);
     } else {
         throw new ParseException("You must call signUp to create a new User.");
     }
 }
Esempio n. 3
0
 /**
  * Execute a find query and return the results.
  *
  * @param boolean $useMasterKey
  *
  * @return array
  */
 public function find($useMasterKey = false)
 {
     $sessionToken = null;
     if (ParseUser::getCurrentUser()) {
         $sessionToken = ParseUser::getCurrentUser()->getSessionToken();
     }
     $queryString = $this->buildQueryString($this->_getOptions());
     $result = ParseClient::_request('GET', '/1/classes/' . $this->className . '?' . $queryString, $sessionToken, null, $useMasterKey);
     $output = array();
     foreach ($result['results'] as $row) {
         $obj = ParseObject::create($this->className, $row['objectId']);
         $obj->_mergeAfterFetchWithSelectedKeys($row, $this->selectedKeys);
         $output[] = $obj;
     }
     return $result;
 }
 /**
  * ParseClient::_decode, internal method for decoding server responses.
  *
  * @param mixed $data The value to decode
  *
  * @return mixed
  * @ignore
  */
 public static function _decode($data)
 {
     // The json decoded response from Parse will make JSONObjects into stdClass
     //   objects.  We'll change it to an associative array here.
     if ($data instanceof \stdClass) {
         $tmp = (array) $data;
         if (!empty($tmp)) {
             return self::_decode(get_object_vars($data));
         }
     }
     if (!$data && !is_array($data)) {
         return null;
     }
     if (is_array($data)) {
         $typeString = isset($data['__type']) ? $data['__type'] : null;
         if ($typeString === 'Date') {
             return new \DateTime($data['iso']);
         }
         if ($typeString === 'Bytes') {
             return base64_decode($data['base64']);
         }
         if ($typeString === 'Pointer') {
             return ParseObject::create($data['className'], $data['objectId']);
         }
         if ($typeString === 'File') {
             return ParseFile::_createFromServer($data['name'], $data['url']);
         }
         if ($typeString === 'GeoPoint') {
             return new ParseGeoPoint($data['latitude'], $data['longitude']);
         }
         if ($typeString === 'Object') {
             $output = ParseObject::create($data['className']);
             $output->_mergeAfterFetch($data);
             return $output;
         }
         if ($typeString === 'Relation') {
             return $data;
         }
         $newDict = array();
         foreach ($data as $key => $value) {
             $newDict[$key] = static::_decode($value);
         }
         return $newDict;
     }
     return $data;
 }