From 1225abcfe516510c1063c0d3896a7d9377b07d02 Mon Sep 17 00:00:00 2001 From: Juvenn Woo Date: Thu, 17 Nov 2016 15:15:32 +0800 Subject: [PATCH] Allow set ACL --- src/LeanCloud/Object.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/LeanCloud/Object.php b/src/LeanCloud/Object.php index aff7acb..be8df91 100644 --- a/src/LeanCloud/Object.php +++ b/src/LeanCloud/Object.php @@ -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. * @@ -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); } @@ -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."); }