Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions soapclient/SforceEnterpriseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function SforceEnterpriseClient() {
* @return SaveResult
*/
public function create($sObjects, $type) {
foreach ($sObjects as &$sObject) {
$arg = [];
foreach ($sObjects as $sObject) {
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
Expand All @@ -59,16 +60,15 @@ public function create($sObjects, $type) {
}
}
// ------

$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
// ------
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
// ------
$arg[] = $soapObject;
}
$arg = $sObjects;

return parent::_create(new SoapParam($arg, "sObjects"));
}
Expand All @@ -81,28 +81,29 @@ public function create($sObjects, $type) {
* @return UpdateResult
*/
public function update($sObjects, $type, $assignment_header = NULL, $mru_header = NULL) {
$arg = new stdClass;
$arg->sObjects = [];
foreach ($sObjects as $sObject) {

foreach ($sObjects as &$sObject) {

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
foreach($sObject->fieldsToNull as $fieldToNull) {
$xmlStr .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>';
}
}
// ------
$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)

$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
// ------
$arg->sObjects[] = $soapObject;
}
$arg = new stdClass;
$arg->sObjects = $sObjects;

return parent::_update($arg);
}

Expand All @@ -119,8 +120,9 @@ public function update($sObjects, $type, $assignment_header = NULL, $mru_header
*/
public function upsert($ext_Id, $sObjects, $type = 'Contact') {
$arg = new stdClass;
$arg->sObjects = [];
$arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
foreach ($sObjects as &$sObject) {
foreach ($sObjects as $sObject) {
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if(isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
Expand All @@ -129,16 +131,17 @@ public function upsert($ext_Id, $sObjects, $type = 'Contact') {
}
}
// ------
$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
// ------
$arg->sObjects[] = $soapObject;
}
$arg->sObjects = $sObjects;

return parent::_upsert($arg);
}

Expand All @@ -155,5 +158,4 @@ public function merge($mergeRequest, $type) {
$arg->request = new SoapVar($mergeRequest, SOAP_ENC_OBJECT, 'MergeRequest', $this->namespace);
return parent::_merge($arg);
}
}
?>
}