You are here

public function CampaignMonitorCampaignCampaignController::draftsOverview in Campaign Monitor 8

1 string reference to 'CampaignMonitorCampaignCampaignController::draftsOverview'
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 107

Class

CampaignMonitorCampaignCampaignController
Campaign Monitor Lists controller.

Namespace

Drupal\campaignmonitor_campaign\Controller

Code

public function draftsOverview() {
  $content = [];
  $drafts_admin_url = Url::fromUri('https://waxeye.createsend.com/subscribers/', [
    'attributes' => [
      'target' => '_blank',
    ],
  ]);
  $drafts_empty_message = t('You don\'t have any drafts 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 drafts, then
      come back here and click "Refresh drafts from Campaign Monitor"', [
    '@link' => Link::fromTextAndUrl(t('Campaign Monitor'), $drafts_admin_url)
      ->toString(),
  ]);
  $content['drafts_table'] = [
    '#type' => 'table',
    '#header' => [
      t('Name'),
      t('Author'),
      t('Created'),
      t('Link'),
    ],
    '#empty' => $drafts_empty_message,
  ];
  $cm_drafts = campaignmonitor_campaign_get_drafts();

  // $total_webhook_events = count(campaignmonitor_default_webhook_events());
  foreach ($cm_drafts as $key => $cm_campaign) {

    // $details = campaignmonitor_get_list_details($key);
    //      $stats = campaignmonitor_get_list_stats($key);
    $content['drafts_table'][$key]['name'] = [
      '#markup' => $cm_campaign['Name'],
    ];
    $content['drafts_table'][$key]['author'] = [
      '#markup' => $cm_campaign['From'],
    ];
    $content['drafts_table'][$key]['sent'] = [
      '#markup' => $cm_campaign['Created'],
    ];
    $content['drafts_table'][$key]['link'] = [
      '#type' => 'link',
      '#title' => 'Preview',
      '#url' => Url::fromUri($cm_campaign['Link']),
    ];
  }
  $refresh_url = Url::fromRoute('campaignmonitor.refresh_drafts', [
    'destination' => 'admin/config/services/campaignmonitor/drafts',
  ]);
  $content['refresh'] = [
    '#type' => 'container',
  ];
  $content['refresh']['refresh_link'] = [
    '#title' => 'Refresh drafts from Campaign Monitor',
    '#type' => 'link',
    '#url' => $refresh_url,
  ];
  return $content;
}