public function CampaignMonitorManager::updateList in Campaign Monitor 8.2
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/
CampaignMonitorManager.php, line 584
Class
- CampaignMonitorManager
- Manager for Campaignmonitor.
Namespace
Drupal\campaignmonitorCode
public function updateList($listId, array $options = []) {
// Make sure that list is loaded.
if (!$this
->getListDetails($listId)) {
$this
->addError($this
->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.
$this->cacheBackend
->set('campaignmonitor_lists', $this->lists);
return TRUE;
}
else {
$this
->addError($result->response->Message, $result->http_status_code);
}
}
return FALSE;
}