Skip to content

Commit

Permalink
Allow set ACL
Browse files Browse the repository at this point in the history
  • Loading branch information
juvenn committed Nov 17, 2016
1 parent 997d72f commit 1225abc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/LeanCloud/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
class Object {

const PRESERVED_KEYS = array("objectId", "ACL",
"updatedAt", "createdAt");
const PRESERVED_KEYS = array("objectId", "updatedAt", "createdAt");
/**
* Map of registered className to class.
*
Expand Down Expand Up @@ -234,6 +233,10 @@ public function getUpdatedAt() {
}

private function _set($key, $val) {
if ($key === "ACL" &&
!($val instanceof ACL)) {
throw new RuntimeException("Invalid ACL.");
}
if (!($val instanceof IOperation)) {
$val = new SetOperation($key, $val);
}
Expand All @@ -250,10 +253,6 @@ private function _set($key, $val) {
* @throws RuntimeException
*/
public function set($key, $val) {
if ($key === "ACL") {
throw new \RuntimeException("`ACL` is preserved,".
" please use setACL instead.");
}
if (in_array($key, self::PRESERVED_KEYS)) {
throw new \RuntimeException("Preserved field could not be set.");
}
Expand Down

0 comments on commit 1225abc

Please sign in to comment.