You are here

protected function CampaignMonitor::__construct in Campaign Monitor 8

Private class constructor, which prevents creation of this class directly. Use the static function CampaignMonitor::GetConnector().

Parameters

string $api_key:

string $client_id:

string $libraryPath: optional.

1 method overrides CampaignMonitor::__construct()
CampaignMonitorCampaign::__construct in modules/campaignmonitor_campaign/src/CampaignMonitorCampaign.php
Private class constructor, which prevents creation of this class directly. Use the static function CampaignMonitor::GetConnector().

File

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

protected function __construct($api_key = FALSE, $client_id = FALSE) {

  // Get account information.
  $this->config = \Drupal::config('campaignmonitor.settings');

  // Get API key/client ID if they are defined.
  $this->apiKey = $api_key ? $api_key : ($this->config
    ->get('api_key') != NULL ? $this->config
    ->get('api_key') : FALSE);
  $this->clientId = $client_id ? $client_id : ($this->config
    ->get('client_id') != NULL ? $this->config
    ->get('client_id') : FALSE);

  // Enable logging.
  if ($this->config
    ->get('logging')) {
    $this->logErrors = $this->config
      ->get('logging');
  }
}