public function CampaignMonitor::createList in Campaign Monitor 8
Create a new list at the Campaign Monitor servers. The side-effect is that 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/CampaignMonitor.php, line 577 
- 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 createList($title, $unsubscribePage = '', $confirmedOptIn = FALSE, $confirmationSuccessPage = '') {
  if ($obj = $this
    ->createListObj(NULL)) {
    $result = $obj
      ->create($this->clientId, [
      'Title' => SafeMarkup::checkPlain($title),
      'UnsubscribePage' => SafeMarkup::checkPlain($unsubscribePage),
      'ConfirmedOptIn' => $confirmedOptIn,
      'ConfirmationSuccessPage' => SafeMarkup::checkPlain($confirmationSuccessPage),
    ]);
    if ($result
      ->was_successful()) {
      // Clear the cache, so the list information can be retrieved again.
      $this
        ->clearCache();
      return TRUE;
    }
    else {
      $this
        ->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
      return FALSE;
    }
  }
  return FALSE;
}