You are here

public function CampaignMonitorManager::getExtendedList in Campaign Monitor 8.2

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/CampaignMonitorManager.php, line 546

Class

CampaignMonitorManager
Manager for 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($this
      ->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($this
      ->t('Could not retrieve extended information for @listID.', [
      '@listID' => $listId,
    ]));
    return FALSE;
  }
  return $this->lists[$listId];
}