You are here

protected function EmailWebformHandler::buildAttachments in Webform 6.x

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

Build attachment to be displayed via debug message and resend form.

Parameters

array $attachments: An array of email attachments.

Return value

array A renderable array containing links to attachments.

2 calls to EmailWebformHandler::buildAttachments()
EmailWebformHandler::buildDebugMessage in src/Plugin/WebformHandler/EmailWebformHandler.php
Build debug message.
EmailWebformHandler::resendMessageForm in src/Plugin/WebformHandler/EmailWebformHandler.php
Build resend message webform.

File

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

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

protected function buildAttachments(array $attachments) {
  $build = [];
  foreach ($attachments as $attachment) {
    $t_args = [
      '@filename' => $attachment['filename'],
      '@filemime' => $attachment['filemime'],
      '@filesize' => format_size(mb_strlen($attachment['filecontent'])),
    ];
    if (!empty($attachment['_fileurl'])) {
      $t_args[':href'] = $attachment['_fileurl'];
      $build[] = [
        '#markup' => $this
          ->t('<strong><a href=":href">@filename</a></strong> (@filemime) - @filesize ', $t_args),
      ];
    }
    else {
      $build[] = [
        '#markup' => $this
          ->t('<strong>@filename</strong> (@filemime) - @filesize ', $t_args),
      ];
    }
  }
  return $build;
}