You are here

public function CampaignMonitor::getExtendedList in Campaign Monitor 8

Get all information available about a given list. This is done by calling getLists(), getListDetails() and getCustomFields(), hence building the local list cache.

Parameters

string $listId: The Campaign Monitor list ID.

Return value

mixed array | FALSE An array containing the list information or FALSE on failure.

File

src/CampaignMonitor.php, line 415
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 getExtendedList($listId) {

  // If the lists have not been loaded yet, get them as they build the basic
  // cache.
  if (empty($this->lists)) {
    $this
      ->getLists();
  }

  // Test that the listId is valid.
  if (!isset($this->lists[$listId])) {
    $this
      ->addError(WATCHDOG_ERROR, t('Unknown list id @listID.', [
      '@listID' => $listId,
    ]));
    return FALSE;
  }

  // Load list details and custom fields (using is_array() since
  // getCustomFields() may return an empty array).
  if (!$this
    ->getListDetails($listId) || !is_array($this
    ->getCustomFields($listId))) {
    $this
      ->addError(WATCHDOG_ERROR, t('Could not retrieve extended information for @listID.', [
      '@listID' => $listId,
    ]));
    return FALSE;
  }
  return $this->lists[$listId];
}