public function HtmlPurifierFilter::process in HTML Purifier 8
Performs the filter processing.
Parameters
string $text: The text string to be filtered.
string $langcode: The language code of the text to be filtered.
Return value
\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.
Overrides FilterInterface::process
See also
\Drupal\filter\FilterProcessResult
File
- src/
Plugin/ Filter/ HtmlPurifierFilter.php, line 30
Class
- HtmlPurifierFilter
- Plugin annotation @Filter( id = "htmlpurifier", title = @Translation("HTML Purifier"), description = @Translation("Removes malicious HTML code and ensures that the output is standards compliant."), type =…
Namespace
Drupal\htmlpurifier\Plugin\FilterCode
public function process($text, $langcode) {
if (!empty($this->settings['htmlpurifier_configuration'])) {
$purifier_config = $this
->applyPurifierConfig($this->settings['htmlpurifier_configuration']);
}
else {
$purifier_config = \HTMLPurifier_Config::createDefault();
}
$purifier = new \HTMLPurifier($purifier_config);
$purified_text = $purifier
->purify($text);
return new FilterProcessResult($purified_text);
}