protected function TextFormat::formatHtmlItem in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/TextFormat.php \Drupal\webform\Plugin\WebformElement\TextFormat::formatHtmlItem()
Format an element's value as HTML.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array|string The element's value formatted as HTML or a render array.
Overrides WebformElementBase::formatHtmlItem
File
- src/
Plugin/ WebformElement/ TextFormat.php, line 220
Class
- TextFormat
- Provides a 'text_format' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
$format = isset($value['format']) ? $value['format'] : $this
->getItemFormat($element);
$value = isset($value['value']) ? $value['value'] : $value;
switch ($format) {
case 'raw':
return $value;
case 'value':
$default_format = filter_default_format(User::load($webform_submission
->getOwnerId()));
return check_markup($value, $default_format);
default:
return check_markup($value, $format);
}
}