protected function _find($filter, $hydrationMode = ETCore::HYDRATE_ARRAY, $one = false)
 {
     $typeName = null;
     if ($filter instanceof ExactTarget_SimpleFilterPart) {
         $typeName = 'SimpleFilterPart';
     } else {
         if ($filter instanceof ExactTarget_ComplexFilterPart) {
             $typeName = 'ComplexFilterPart';
         } else {
             throw new ETException('First parameter must be of type ExactTarget_SimpleFilterPart or ExactTarget_ComplexFilterPart.');
         }
     }
     $rr = new ExactTarget_RetrieveRequest();
     $rr->ObjectType = "Subscriber";
     $rr->Properties = $this->retrievableProperties();
     $rr->Filter = ETCore::toSoapVar($filter, $typeName);
     $rr->Options = null;
     $rrm = new ExactTarget_RetrieveRequestMsg();
     $rrm->RetrieveRequest = $rr;
     $result = $this->soapClient->Retrieve($rrm);
     ETCore::evaluateSoapResult($result);
     return $this->hydrate($result, $hydrationMode, $one);
 }
 /**
  * Save the record.
  *
  * @return type
  */
 public function save()
 {
     try {
         if (count($this->modifiedFiels) == 0) {
             return false;
         }
         $deoSo = $this->makeSoapVarForSave();
         $uo = new ExactTarget_UpdateOptions();
         $uo->SaveOptions = array();
         $so = new ExactTarget_SaveOption();
         $so->PropertyName = 'DataExtensionObject';
         $so->SaveAction = ExactTarget_SaveAction::UpdateAdd;
         $uo->SaveOptions[] = $so;
         $uoSo = ETCore::toSoapVar($uo, 'UpdateOptions');
         $request = new ExactTarget_UpdateRequest();
         $request->Options = $uoSo;
         $request->Objects = array($deoSo);
         $result = $this->soapClient->Update($request);
         $this->evaluateResult($result);
         return true;
     } catch (Exception $e) {
         throw new ETException(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
     }
 }
Beispiel #3
0
 /**
  *    声明模板用法
  */
 function template($set = array('ID' => '1', 'TplType' => 'htm', 'CacheDir' => 'cache', 'TemplateDir' => 'template', 'AutoImage' => 'on', 'LangDir' => 'language', 'Language' => 'default', 'Copyright' => 'off', 'MemCache' => ''))
 {
     parent::ETCoreStart($set);
 }
 /**
  * Delete all records from this collection.
  */
 public function delete()
 {
     $data = array();
     if (count($this->data) === 0) {
         return true;
     }
     try {
         foreach ($this->data as $rec) {
             $data[] = $rec->toSoapVarForDelete();
         }
         $result = ETCore::delete($data);
         ETCore::evaluateSoapResult($result);
         return true;
     } catch (Exception $e) {
         throw new ETException(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
     }
 }
 /**
  * Get all records from the table (data extension).
  *
  * @param integer $hydrationMode ETCore::HYDRATE_ARRAY will return an array
  *                               representation of the records in the table.
  *                               ETCore::HYDRATE_RECORD will return an
  *                               ETCollection that contains xxxObject objects.
  * @return mixed ETCollection or Array, depending on hydration mode.
  * @throws Exception
  */
 public function findAll($hydrationMode = ETCore::HYDRATE_ARRAY)
 {
     try {
         $res = null;
         $rr = new ExactTarget_RetrieveRequest();
         $rr->ObjectType = 'DataExtensionObject[' . $this->customerKey . ']';
         $rr->Properties = $this->schema;
         $rr->Options = null;
         $rrm = new ExactTarget_RetrieveRequestMsg();
         $rrm->RetrieveRequest = $rr;
         $result = $this->soapClient->Retrieve($rrm);
         ETCore::evaluateSoapResult($result);
         $records = array();
         if (!property_exists($result, 'Results')) {
             $result->Results = array();
         }
         if (!is_array($result->Results)) {
             $result->Results = array($result->Results);
         }
         foreach ($result->Results as $fields) {
             $record = array();
             foreach ($fields->Properties->Property as $field) {
                 $record[$field->Name] = $field->Value;
             }
             if (count($record) > 0) {
                 $records[] = $record;
             }
         }
         if ($hydrationMode == ETCore::HYDRATE_ARRAY) {
             $res = $records;
         } else {
             $coll = new ETCollection();
             foreach ($records as $record) {
                 $eo = new $this->extensionObjectClassName();
                 $eo->fromArray($record);
                 $coll->add($eo);
             }
             $res = $coll;
         }
         return $res;
     } catch (Exception $e) {
         throw new ETException(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
     }
 }
 /**
  * ExactTarget SOAP update that allows the update action to be specified.
  *
  * @param array   $objects Array of SOAP objects to be updated
  * @param integet $saveAction A constant integer specifying the action.
  *
  * @return ExactTarget SOAP response
  * $throws Exception
  */
 protected static function _update($objects, $saveAction)
 {
     try {
         $soapClient = self::getClient();
         $uo = new ExactTarget_UpdateOptions();
         $uo->SaveOptions = array();
         $so = new ExactTarget_SaveOption();
         $so->PropertyName = '*';
         $so->SaveAction = $saveAction;
         $uo->SaveOptions[] = $so;
         $uoSo = ETCore::toSoapVar($uo, 'UpdateOptions');
         $request = new ExactTarget_UpdateRequest();
         $request->Options = $uoSo;
         $request->Objects = $objects;
         return $soapClient->Update($request);
     } catch (Exception $e) {
         throw new ETException(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
     }
 }
 /**
  * Helper method that creates a SoapVar object.
  *
  * @return SoapVar
  */
 protected function makeSoapVar()
 {
     $subscriber = new ExactTarget_Subscriber();
     $this->modifiedProperties = array_unique(array_merge($this->modifiedProperties, $this->requiredProperties));
     foreach ($this->modifiedProperties as $propName) {
         $subscriber->{$propName} = $this->properties[$propName];
     }
     $subscriber->Attributes = array();
     $this->modifiedAttributes = array_unique(array_merge($this->modifiedAttributes, $this->requiredAttributes));
     foreach ($this->modifiedAttributes as $attrName) {
         $subscriber->Attributes[] = ETCore::newAttribute($attrName, $this->attributes[$attrName]);
     }
     return ETCore::toSoapVar($subscriber, 'Subscriber');
 }