You are here

public function CampaignMonitorCampaignCampaignController::campaignsOverview in Campaign Monitor 8

1 string reference to 'CampaignMonitorCampaignCampaignController::campaignsOverview'
campaignmonitor_campaign.routing.yml in modules/campaignmonitor_campaign/campaignmonitor_campaign.routing.yml
modules/campaignmonitor_campaign/campaignmonitor_campaign.routing.yml

File

modules/campaignmonitor_campaign/src/Controller/CampaignMonitorCampaignCampaignController.php, line 54

Class

CampaignMonitorCampaignCampaignController
Campaign Monitor Lists controller.

Namespace

Drupal\campaignmonitor_campaign\Controller

Code

public function campaignsOverview() {
  $content = [];
  $campaigns_admin_url = Url::fromUri('https://waxeye.createsend.com/subscribers/', [
    'attributes' => [
      'target' => '_blank',
    ],
  ]);
  $campaigns_empty_message = t('You don\'t have any campaigns configured in your
      Campaign Monitor account, (or you haven\'t configured your API key correctly on
      the Global Settings tab). Head over to @link and create some campaigns, then
      come back here and click "Refresh campaigns from Campaign Monitor"', [
    '@link' => Link::fromTextAndUrl(t('Campaign Monitor'), $campaigns_admin_url)
      ->toString(),
  ]);
  $content['campaigns_table'] = [
    '#type' => 'table',
    '#header' => [
      t('Name'),
      t('Sent'),
      t('Link'),
    ],
    '#empty' => $campaigns_empty_message,
  ];
  $cm_campaigns = campaignmonitor_campaign_get_campaigns();
  foreach ($cm_campaigns as $key => $cm_campaign) {

    // $details = campaignmonitor_get_list_details($key);
    //      $stats = campaignmonitor_get_list_stats($key);
    $content['campaigns_table'][$key]['name'] = [
      '#markup' => $cm_campaign['Name'],
    ];
    $content['campaigns_table'][$key]['sent'] = [
      '#markup' => $cm_campaign['Sent'],
    ];
    $content['campaigns_table'][$key]['link'] = [
      '#markup' => $cm_campaign['Link'],
    ];
  }
  $refresh_url = Url::fromRoute('campaignmonitor.refresh_campaigns', [
    'destination' => 'admin/config/services/campaignmonitor/campaigns',
  ]);
  $content['refresh'] = [
    '#type' => 'container',
  ];
  $content['refresh']['refresh_link'] = [
    '#title' => 'Refresh campaigns from Campaign Monitor',
    '#type' => 'link',
    '#url' => $refresh_url,
  ];
  return $content;
}