You are here

public function CampaignMonitorManager::createList in Campaign Monitor 8.2

Create a new list at the Campaign Monitor servers.

The side-effect: the local cache is cleared.

Parameters

string $title: The title of the new list.

string $unsubscribePage: An optional page to redirect subscribers to when they unsubscribe.

bool $confirmedOptIn: Whether or not this list requires to confirm the subscription. Defaults to FALSE.

string $confirmationSuccessPage: An optional page to redirect subscribers to when they confirm their subscription.

Return value

bool TRUE on success, FALSE otherwise.

File

src/CampaignMonitorManager.php, line 728

Class

CampaignMonitorManager
Manager for Campaignmonitor.

Namespace

Drupal\campaignmonitor

Code

public function createList($title, $unsubscribePage = '', $confirmedOptIn = FALSE, $confirmationSuccessPage = '') {
  if ($obj = $this
    ->createListObj(NULL)) {
    $result = $obj
      ->create($this->clientId, [
      'Title' => HTML::escape($title),
      'UnsubscribePage' => HTML::escape($unsubscribePage),
      'ConfirmedOptIn' => $confirmedOptIn,
      'ConfirmationSuccessPage' => HTML::escape($confirmationSuccessPage),
    ]);
    if ($result
      ->was_successful()) {

      // Clear the cache, so the list information can be retrieved again.
      $this
        ->clearCache();
      return TRUE;
    }
    else {
      $this
        ->addError($result->response->Message, $result->http_status_code);
      return FALSE;
    }
  }
  return FALSE;
}