You are here

protected function Address::formatTextItem in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/Address.php \Drupal\webform\Plugin\WebformElement\Address::formatTextItem()

Format an element's value as text.

Parameters

array $element: An element.

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

array $options: An array of options.

Return value

string The element's value formatted as text.

Overrides WebformCompositeBase::formatTextItem

See also

_webform_token_get_submission_value()

File

src/Plugin/WebformElement/Address.php, line 248

Class

Address
Provides a 'address' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
  $format = $this
    ->getItemFormat($element);
  if ($format === 'value') {
    $build = $this
      ->buildAddress($element, $webform_submission, $options);
    $html = $this->renderer
      ->renderPlain($build);
    return trim(MailFormatHelper::htmlToText($html));
  }
  else {
    return parent::formatTextItem($element, $webform_submission, $options);
  }
}