You are here

public function ProcessedText::buildText in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/ProcessedText.php \Drupal\webform\Plugin\WebformElement\ProcessedText::buildText()

Build an element as text element.

Parameters

array $element: An element.

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

array $options: An array of options.

Return value

array A render array representing an element as text.

Overrides WebformMarkupBase::buildText

File

src/Plugin/WebformElement/ProcessedText.php, line 60

Class

ProcessedText
Provides a 'processed_text' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function buildText(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {

  // Copy to element so that we can render it without altering the actual
  // $element.
  $render_element = $element;
  $html = (string) \Drupal::service('renderer')
    ->renderPlain($render_element);
  $element['#markup'] = MailFormatHelper::htmlToText($html);

  // Must remove #type, #text, and #format.
  unset($element['#type'], $element['#text'], $element['#format']);
  return parent::buildText($element, $webform_submission, $options);
}