Skip to content

Commit 99ec49b

Browse files
committed
Merge pull request #29 from egreenmachine/save-master-key
Allow saving Parse Objects with Master Key
2 parents 97bb205 + a780976 commit 99ec49b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Parse/ParseObject.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,38 +818,42 @@ private function getSaveJSON()
818818
/**
819819
* Save Object to Parse
820820
*
821+
* @param bool $useMasterKey Whether to use the Master Key.
822+
*
821823
* @return null
822824
*/
823-
public function save()
825+
public function save($useMasterKey = false)
824826
{
825827
if (!$this->isDirty()) {
826828
return;
827829
}
828-
static::deepSave($this);
830+
static::deepSave($this, $useMasterKey);
829831
}
830832

831833
/**
832834
* Save all the objects in the provided array
833835
*
834836
* @param array $list
837+
* @param bool $useMasterKey Whether to use the Master Key.
835838
*
836839
* @return null
837840
*/
838-
public static function saveAll($list)
841+
public static function saveAll($list, $useMasterKey = false)
839842
{
840-
static::deepSave($list);
843+
static::deepSave($list, $useMasterKey);
841844
}
842845

843846
/**
844847
* Save Object and unsaved children within.
845848
*
846849
* @param $target
850+
* @param bool $useMasterKey Whether to use the Master Key.
847851
*
848852
* @return null
849853
*
850854
* @throws ParseException
851855
*/
852-
private static function deepSave($target)
856+
private static function deepSave($target, $useMasterKey = false)
853857
{
854858
$unsavedChildren = array();
855859
$unsavedFiles = array();
@@ -916,7 +920,7 @@ private static function deepSave($target)
916920
$batch[0]->mergeAfterSave($result);
917921
} else {
918922
$result = ParseClient::_request('POST', '/1/batch', $sessionToken,
919-
json_encode(array("requests" => $requests)));
923+
json_encode(array("requests" => $requests)), $useMasterKey);
920924

921925
$errorCollection = array();
922926

0 commit comments

Comments
 (0)