当前位置: 首页>>代码示例>>PHP>>正文


PHP ParseClient::getMountPath方法代码示例

本文整理汇总了PHP中Parse\ParseClient::getMountPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseClient::getMountPath方法的具体用法?PHP ParseClient::getMountPath怎么用?PHP ParseClient::getMountPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse\ParseClient的用法示例。


在下文中一共展示了ParseClient::getMountPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deepSave

 /**
  * Save object and unsaved children within.
  *
  * @param ParseObject|array $target
  * @param bool              $useMasterKey Whether to use the Master Key.
  *
  * @throws Exception
  * @throws ParseAggregateException
  * @throws ParseException
  */
 private static function deepSave($target, $useMasterKey = false)
 {
     $unsavedChildren = [];
     $unsavedFiles = [];
     static::findUnsavedChildren($target, $unsavedChildren, $unsavedFiles);
     $sessionToken = null;
     if (ParseUser::getCurrentUser()) {
         $sessionToken = ParseUser::getCurrentUser()->getSessionToken();
     }
     foreach ($unsavedFiles as &$file) {
         $file->save();
     }
     $objects = [];
     // Get the set of unique objects among the children.
     foreach ($unsavedChildren as &$obj) {
         if (!in_array($obj, $objects, true)) {
             $objects[] = $obj;
         }
     }
     $remaining = $objects;
     while (count($remaining) > 0) {
         $batch = [];
         $newRemaining = [];
         foreach ($remaining as $key => &$object) {
             if (count($batch) > 40) {
                 $newRemaining[] = $object;
                 continue;
             }
             if ($object->canBeSerialized()) {
                 $batch[] = $object;
             } else {
                 $newRemaining[] = $object;
             }
         }
         $remaining = $newRemaining;
         if (count($batch) === 0) {
             throw new Exception('Tried to save a batch with a cycle.');
         }
         $requests = [];
         foreach ($batch as $obj) {
             $json = $obj->getSaveJSON();
             $method = 'POST';
             $path = 'classes/' . $obj->getClassName();
             if ($obj->getObjectId()) {
                 $path .= '/' . $obj->getObjectId();
                 $method = 'PUT';
             }
             $requests[] = ['method' => $method, 'path' => $path, 'body' => $json];
         }
         if (count($requests) === 1) {
             $req = $requests[0];
             $result = ParseClient::_request($req['method'], $req['path'], $sessionToken, json_encode($req['body']), $useMasterKey);
             $batch[0]->mergeAfterSave($result);
         } else {
             foreach ($requests as &$r) {
                 $r['path'] = '/' . ParseClient::getMountPath() . $r['path'];
             }
             $result = ParseClient::_request('POST', 'batch', $sessionToken, json_encode(['requests' => $requests]), $useMasterKey);
             $errorCollection = [];
             foreach ($batch as $key => &$obj) {
                 if (isset($result[$key]['success'])) {
                     $obj->mergeAfterSave($result[$key]['success']);
                 } elseif (isset($result[$key]['error'])) {
                     $response = $result[$key];
                     $error = $response['error']['error'];
                     $code = isset($response['error']['code']) ? $response['error']['code'] : -1;
                     $errorCollection[] = ['error' => $error, 'code' => $code, 'object' => $obj];
                 } else {
                     $errorCollection[] = ['error' => 'Unknown error in batch save.', 'code' => -1, 'object' => $obj];
                 }
             }
             if (count($errorCollection)) {
                 throw new ParseAggregateException('Errors during batch save.', $errorCollection);
             }
         }
     }
 }
开发者ID:bohemima,项目名称:parse-php-sdk,代码行数:87,代码来源:ParseObject.php


注:本文中的Parse\ParseClient::getMountPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。