You are here

protected function EmailWebformHandler::buildDebugMessage in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformHandler/EmailWebformHandler.php \Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::buildDebugMessage()

Build debug message.

Parameters

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

array $message: An email message.

Return value

array Debug message.

2 calls to EmailWebformHandler::buildDebugMessage()
EmailWebformHandler::sendMessage in src/Plugin/WebformHandler/EmailWebformHandler.php
Sends and logs a webform submission message.
ScheduleEmailWebformHandler::scheduleMessage in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Schedule the sending of an email.

File

src/Plugin/WebformHandler/EmailWebformHandler.php, line 1382

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

protected function buildDebugMessage(WebformSubmissionInterface $webform_submission, array $message) {

  // Title.
  $build = [
    '#type' => 'details',
    '#title' => $this
      ->t('Debug: Email: @title', [
      '@title' => $this
        ->label(),
    ]),
  ];

  // Values.
  $values = [
    'from_name' => $this
      ->t('From name'),
    'from_mail' => $this
      ->t('From mail'),
    'to_mail' => $this
      ->t('To mail'),
    'cc_mail' => $this
      ->t('Cc mail'),
    'bcc_mail' => $this
      ->t('Bcc mail'),
    'reply_to' => $this
      ->t('Reply-to'),
    'return_path' => $this
      ->t('Return path'),
    '---' => '---',
    'subject' => $this
      ->t('Subject'),
  ];
  foreach ($values as $name => $title) {
    if ($title === '---') {
      $build[$name] = [
        '#markup' => '<hr />',
      ];
    }
    elseif (!empty($message[$name])) {
      $build[$name] = [
        '#type' => 'item',
        '#title' => $title,
        '#markup' => $message[$name],
        '#wrapper_attributes' => [
          'class' => [
            'container-inline',
          ],
          'style' => 'margin: 0',
        ],
      ];
    }
  }

  // Body.
  $build['body'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Body'),
    '#markup' => Markup::create('<pre>' . htmlentities($message['body']) . '</pre>'),
    '#wrapper_attributes' => [
      'style' => 'margin: 0',
    ],
  ];

  // Attachments.
  if (!empty($message['attachments'])) {
    $build['attachments_divider'] = [
      '#markup' => '<hr />',
    ];
    $build['attachments'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Attachments'),
      '#wrapper_attributes' => [
        'style' => 'margin: 0',
      ],
      'files' => $this
        ->buildAttachments($message['attachments']),
    ];
  }
  return $build;
}