コード例 #1
0
ファイル: AVACL.php プロジェクト: c0710204/avos-php-sdk
 /**
  * Create new AVACL from existing permissions.
  *
  * @param array $data represents permissions.
  *
  * @return AVACL
  * @throws \Exception
  * @ignore
  */
 public static function _createACLFromJSON($data)
 {
     $acl = new AVACL();
     foreach ($data as $id => $permissions) {
         if (!is_string($id)) {
             throw new \Exception('Tried to create an ACL with an invalid userId.');
         }
         foreach ($permissions as $accessType => $value) {
             if ($accessType !== 'read' && $accessType !== 'write') {
                 throw new \Exception('Tried to create an ACL with an invalid permission type.');
             }
             if (!is_bool($value)) {
                 throw new \Exception('Tried to create an ACL with an invalid permission value.');
             }
             $acl->setAccess($accessType, $id, $value);
         }
     }
     return $acl;
 }