You are here

public function CampaignMonitor::deleteList in Campaign Monitor 8

Delete a list from Campaign Monitor. This action can not be reverted. The list is also removed from the local cache.

Parameters

mixed $listId: The Campaign Monitor list ID.

Return value

bool TRUE on success, FALSE otherwise.

File

src/CampaignMonitor.php, line 543
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

CampaignMonitor

Namespace

Drupal\campaignmonitor

Code

public function deleteList($listId) {
  if ($obj = $this
    ->createListObj($listId)) {
    $result = $obj
      ->delete();
    if ($result
      ->was_successful()) {
      unset($this->lists[$listId]);
      \Drupal::cache()
        ->set('campaignmonitor_lists', $this->lists, $this
        ->getCacheTimeout());
      return TRUE;
    }
    else {
      $this
        ->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
      return FALSE;
    }
  }
  return FALSE;
}