Beispiel #1
0
 /**
  * Create a Salesforce object
  *
  * Converts PHP \DateTimes to their SOAP equivalents.
  *
  * @param object $object     Any object with public properties
  * @param string $objectType Salesforce object type
  *
  * @return object
  */
 protected function createSObject($object, $objectType)
 {
     $sObject = new \stdClass();
     foreach (get_object_vars($object) as $field => $value) {
         $type = $this->soapClient->getSoapElementType($objectType, $field);
         if ($field != 'Id' && !$type) {
             continue;
         }
         if ($value === null) {
             $sObject->fieldsToNull[] = $field;
             continue;
         }
         // As PHP \DateTime to SOAP dateTime conversion is not done
         // automatically with the SOAP typemap for sObjects, we do it here.
         switch ($type) {
             case 'date':
                 if ($value instanceof \DateTime) {
                     $value = $value->format('Y-m-d');
                 }
                 break;
             case 'dateTime':
                 if ($value instanceof \DateTime) {
                     $value = $value->format('Y-m-d\\TH:i:sP');
                 }
                 break;
             case 'base64Binary':
                 $value = base64_encode($value);
                 break;
         }
         $sObject->{$field} = $value;
     }
     return $sObject;
 }
Beispiel #2
0
 /**
  * @param Wsdl  $wsdl
  * @param array $options
  */
 public function __construct(Wsdl $wsdl, array $options = array())
 {
     parent::__construct($wsdl->getPathname(), $options);
     $this->wsdl = $wsdl;
 }