You are here

private function MailchimpCampaignForm::parseTemplateContent in Mailchimp 8

Same name and namespace in other branches
  1. 2.x modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php \Drupal\mailchimp_campaign\Form\MailchimpCampaignForm::parseTemplateContent()

Parses template content to remove wrapper elements from tree.

Parameters

array $content: The template content array.

Return value

array The template content array minus wrapper elements.

2 calls to MailchimpCampaignForm::parseTemplateContent()
MailchimpCampaignForm::preview in modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php
Generates a preview of the campaign template content.
MailchimpCampaignForm::validateForm in modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…

File

modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php, line 794

Class

MailchimpCampaignForm
Form controller for the MailchimpCampaign entity edit form.

Namespace

Drupal\mailchimp_campaign\Form

Code

private function parseTemplateContent(array $content) {
  $template_content = [];
  $content_keys = array_keys($content);
  foreach ($content_keys as $content_key) {
    if (strpos($content_key, '_wrapper') !== FALSE) {

      // If this element is a wrapper, add the element contained
      // within the wrapper to the template content.
      $new_content_key = str_replace('_wrapper', '', $content_key);
      $template_content[$new_content_key] = $content[$content_key][$new_content_key];
    }
    else {

      // If this element is not a wrapper, add it to the template content.
      $template_content[$content_key] = $content[$content_key];
    }
  }
  return $template_content;
}