You are here

public function CampaignMonitorCampaignSendForm::submitForm in Campaign Monitor 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

modules/campaignmonitor_campaign/src/Form/CampaignMonitorCampaignSendForm.php, line 103

Class

CampaignMonitorCampaignSendForm
Campaign Monitor send form.

Namespace

Drupal\campaignmonitor_campaign\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $storage = $form_state
    ->getStorage();
  $node = $storage['node'];

  // Get settings.
  $settings = campaignmonitor_campaign_get_node_settings('all', $node
    ->bundle());
  $filepath = $this
    ->createHtmlFile($settings, $node);
  $data = $this
    ->createDataPacket($settings, $node, $filepath);
  $cm_campaign = new CampaignMonitorCampaign();
  if ($cm_campaign
    ->createCampaign($data)) {
    drupal_set_message(t('Your campaign has been sent!!.'));
  }
  else {
    drupal_set_message(t('Your campaign failed to send.'));
  }
}