An Inx_Api_Recipient_BatchChannel can (and should) be used for manipulation of large amounts of data.
An Inx_Api_Recipient_BatchChannel can (and should) be used for manipulation of large amounts of data. The createRecipient() and selectRecipient() methods are used to create and/or select a recipient. After creating or selecting a recipient, the following batch commands operate on this until another recipient is selected. An Inx_Api_Recipient_BatchChannel may be used to perform the following operations:
Note: Resubscription is not supported by
The following snippet shows how to add two new addresses and change their "Firstname" and "Lastname" attributes. If the addresses exist already, these attribute values will be overwritten.
$oRecipientContext = $oSession->createRecipientContext(); $oBatchChannel = $oRecipientContext->createBatchChannel(); $oRecipientMetaData = $oRecipientContext->getMetaData(); $oBatchChannel->createRecipient( "mueller@yourcompany.com", true ); $oBatchChannel->write( $oRecipientMetaData->getUserAttribute( "Firstname" ), "George" ); $oBatchChannel->write( $oRecipientMetaData->getUserAttribute( "Lastname" ), "Müller" ); $oBatchChannel->createRecipient( "clinton@yourcompany.com", true ); $oBatchChannel->write( $oRecipientMetaData->getUserAttribute( "Firstname" ), "Bill" ); $oBatchChannel->write( $oRecipientMetaData->getUserAttribute( "Lastname" ), "Clinton" ); $retArr = $oBatchChannel->executeBatch();Note: The boolean parameter of createRecipient defines how to handle already existent recipients. If the parameter is set to true - as in the example - the recipient will only be created if it does not already exist. Existent recipients are selected instead. If the parameter is set to false the BatchChannel will attempt to create the recipient. If the recipient is not already existing it will be created and selected. However, if the recipient exists already, the result will be RESULT_FAILURE_DUPLICATE_KEY and the recipient will <strong>not</strong> be selected. Therefore, all succeeding operations on this recipient will not be committed (RESULT_NOT_COMMITTED).
The selection and removal of recipients works very much the same, except that removeRecipient($sKeyValue) will not select the deleted recipient of course. After deleting a recipient, a new recipient must be selected (or created) before any tasks may be invoked. This is because the remove() method resets the currently selected recipient.
The writeIfNull($oAttribute, $sValue) method allows you to set an attribute value only, if no value was assigned previously (i.e. the attribute value is null). A similar technique is used by subscribeIfNotUnsubscribed($oListContext, $sDate). This method subscribes the selected recipient to the given list, only when the recipient was not unsubscribed from that list before.
Each command to the BatchChannel results in a value in the returned integer array. By scanning the array, you can find out which of the commands have been executed, and which have not.
The values produced by
:The values produced by selectRecipient():
The values produced by createRecipient():
The values produced by write() and writeIfNull()
The values produced by subscribeIfNotUnsubscribed()
The values produced by unsubscribe()
For more information on recipients, see the Inx_Api_Recipient_RecipientContext documentation.
Located in /Api/Recipient/BatchChannel.php (line 124)
Create and/or select a recipient identified by the given key value.
Create and/or select a recipient identified by the given key value. The behaviour of this method depends on the value of the bool parameter and the recipient state (existing or not existing). The behaviour is defined as follows:
Execute the batched commands.
Execute the batched commands.
Retrieves the Inx_Api_Recipient_RecipientContext which created this BatchChannel.
Retrieves the Inx_Api_Recipient_RecipientContext which created this BatchChannel.
Removes the recipient identified by the given key value from the system.
Removes the recipient identified by the given key value from the system. A key different from the email address may be specified using Inx_Api_Recipient_RecipientContext::createBatchChannel($oAttribute). However, be careful with that method, as the selected recipient for non unique key attributes is not determined. In such a case, any of the matching recipients may be removed.
Selects an existing recipient identified by the given key value.
Selects an existing recipient identified by the given key value. A key different from the email address may be specified using Inx_Api_Recipient_RecipientContext::createBatchChannel($oAttribute). However, be careful with that method, as the selected recipient for non unique key attributes is not determined. In such a case, any of the matching recipients may be selected.
Subscribes a new recipient to the given list, if she/he was not unsubscribed from it before.
Subscribes a new recipient to the given list, if she/he was not unsubscribed from it before. Use the write() method to overwrite the unsubscription of the recipient or use Inx_Api_Recipient_UnsubscriptionRecipientRowSet::resubscribe($sDate) instead.
Unsubscribes the current recipient from the specified list.
Unsubscribes the current recipient from the specified list. Requires a previously invoked select or create command and the recipient must be a member of the list.
Sets a new value to the specified attribute.
Sets a new value to the specified attribute. Requires a previously invoked select or create command. If the attribute is changed several times during a batch command, the last will be the new value.
Sets a new value to the specified attribute, only if the current value is null.
Sets a new value to the specified attribute, only if the current value is null. Requires a previously invoked select or create command. If this method is invoked several times during a batch command, the first value will be set.
RESULT_COMMITTED is returned if the value is set and committed.
RESULT_COMMITTED is returned if the value is set and committed.
RESULT_FAILURE_BLOCKED_BY_BLACKLIST is returned if the email address is blocked by a blacklist entry.
RESULT_FAILURE_BLOCKED_BY_BLACKLIST is returned if the email address is blocked by a blacklist entry.
RESULT_FAILURE_DUPLICATE_KEY is returned if the unique key already exists.
RESULT_FAILURE_DUPLICATE_KEY is returned if the unique key already exists.
RESULT_FAILURE_ILLEGAL_VALUE is returned if the key value is illegal.
RESULT_FAILURE_ILLEGAL_VALUE is returned if the key value is illegal.
RESULT_FAILURE_KEY_NOT_FOUND is returned if the recipient doesn't exist.
RESULT_FAILURE_KEY_NOT_FOUND is returned if the recipient doesn't exist.
RESULT_NOT_COMMITTED is returned if the data was not committed.
RESULT_NOT_COMMITTED is returned if the data was not committed.
RESULT_PERMISSION_DENIED is returned if the permission is denied to create, update or remove a recipient.
RESULT_PERMISSION_DENIED is returned if the permission is denied to create, update or remove a recipient.
Documentation generated on Thu, 17 Sep 2015 14:27:21 +0200 by phpDocumentor 1.3.2