You are here

public static function WebformAttachmentTwig::getFileContent in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_attachment/src/Element/WebformAttachmentTwig.php \Drupal\webform_attachment\Element\WebformAttachmentTwig::getFileContent()

Get a webform attachment's file content.

Parameters

array $element: The webform attachment element.

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

Return value

mixed|string The attachment's file content.

Overrides WebformAttachmentInterface::getFileContent

File

modules/webform_attachment/src/Element/WebformAttachmentTwig.php, line 27

Class

WebformAttachmentTwig
Provides a 'webform_attachment_twig' element.

Namespace

Drupal\webform_attachment\Element

Code

public static function getFileContent(array $element, WebformSubmissionInterface $webform_submission) {
  $options = [];
  $template = $element['#template'];
  $content = WebformTwigExtension::renderTwigTemplate($webform_submission, $template, $options);
  return !empty($element['#trim']) ? trim($content) : $content;
}