public function CampaignMonitor::updateList in Campaign Monitor 8
Update remote list information. The options array should have the fields "Title", "UnsubscribePage", "ConfirmedOptIn" and "ConfirmationSuccessPage". If you do not wish to set these use an empty string.
Parameters
string $listId: The Campaign Monitor list ID.
array $options: An array of options with information to update.
Return value
bool TRUE on success, FALSE otherwise.
File
- src/
CampaignMonitor.php, line 451 - Implementation of the CampaignMonitor class, which is a wrapper class for Campaign Monitor v3 API. It's implemented as a Singleton class and instances are created using the account variables and the static function getConnector(). An example:.
Class
Namespace
Drupal\campaignmonitorCode
public function updateList($listId, $options = []) {
// Make sure that list is loaded.
if (!$this
->getListDetails($listId)) {
$this
->addError(WATCHDOG_ERROR, t('Could not retrieve update list information for @listID.', [
'@listID' => $listId,
]));
return FALSE;
}
// Get list object and update the list.
if ($obj = $this
->createListObj($listId)) {
// @todo: check that the options are correct.
$result = $obj
->update($options);
if ($result
->was_successful()) {
// Update local list cache.
$this->lists[$listId]['name'] = $options['Title'];
$this->lists[$listId]['details']['UnsubscribePage'] = $options['UnsubscribePage'];
$this->lists[$listId]['details']['ConfirmedOptIn'] = $options['ConfirmedOptIn'];
$this->lists[$listId]['details']['ConfirmationSuccessPage'] = $options['ConfirmationSuccessPage'];
// Update the cache.
\Drupal::cache()
->set('campaignmonitor_lists', $this->lists);
return TRUE;
}
else {
$this
->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
}
}
return FALSE;
}