public static function WebformHtmlHelper::toHtmlMarkup in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformHtmlHelper.php \Drupal\webform\Utility\WebformHtmlHelper::toHtmlMarkup()
Convert string to safe HTML markup.
Parameters
string $string: Text to be converted to safe HTML markup.
array $html_tags: An array of HTML tags.
Return value
\Drupal\Component\Render\MarkupInterface|string Safe HTML markup or a plain text string.
6 calls to WebformHtmlHelper::toHtmlMarkup()
- TextBase::validatePattern in src/
Plugin/ WebformElement/ TextBase.php - Form API callback. Validate unicode pattern and display a custom error.
- WebformElementBase::prepare in src/
Plugin/ WebformElementBase.php - Prepare an element to be rendered within a webform.
- WebformElementBase::validateUnique in src/
Plugin/ WebformElementBase.php - Form API callback. Validate element #unique value.
- WebformElementBase::validateUniqueMultiple in src/
Plugin/ WebformElementBase.php - Form API callback. Validate element #unique multiple values.
- WebformHtmlHelperTest::testToHtmlMarkup in tests/
src/ Unit/ Utility/ WebformHtmlHelperTest.php - Tests WebformHtmlHelper::containsToHtmlMarkup().
File
- src/
Utility/ WebformHtmlHelper.php, line 46
Class
- WebformHtmlHelper
- Provides HTML helper functions.
Namespace
Drupal\webform\UtilityCode
public static function toHtmlMarkup($string, array $html_tags = NULL) {
$html_tags = $html_tags ?: WebformHtmlEditor::getAllowedTags();
if (static::containsHtml($string)) {
return Markup::create(Xss::filter($string, $html_tags));
}
else {
return $string;
}
}