public function batchObjects($objects, $objectIDKey = 'objectID', $objectActionKey = 'objectAction')
{
$requests = array();
$allowedActions = array('addObject', 'updateObject', 'deleteObject', 'partialUpdateObject', 'partialUpdateObjectNoCreate');
foreach ($objects as $obj) {
// If no or invalid action, assume updateObject
if (!isset($obj[$objectActionKey]) || !in_array($obj[$objectActionKey], $allowedActions)) {
throw new \Exception('invalid or no action detected');
}
$action = $obj[$objectActionKey];
// The action key is not included in the object
unset($obj[$objectActionKey]);
$req = array('action' => $action, 'body' => $obj);
if (array_key_exists($objectIDKey, $obj)) {
$req['objectID'] = (string) $obj[$objectIDKey];
}
$requests[] = $req;
}
return $this->batch(array('requests' => $requests));
}