protected function SpamspanDomTrait::toStringHtmlDocument in SpamSpan filter 8.2
Same name and namespace in other branches
- 8 src/SpamspanDomTrait.php \Drupal\spamspan\SpamspanDomTrait::toStringHtmlDocument()
Convert DOM Document back to html.
Parameters
\DOMDocument $document: DOM Document.
Return value
string Html.
1 call to SpamspanDomTrait::toStringHtmlDocument()
- SpamspanDomTrait::processAsDom in src/
SpamspanDomTrait.php - Replaces email addresses using DOM and regex.
File
- src/
SpamspanDomTrait.php, line 117
Class
- SpamspanDomTrait
- Trait SpamspanDomTrait.
Namespace
Drupal\spamspanCode
protected function toStringHtmlDocument(\DOMDocument $document) {
foreach ($document->childNodes as $item) {
if ($item->nodeType == XML_PI_NODE) {
$document
->removeChild($item);
break;
}
}
// Use saveHTML(documentElement) instead of simply saveHTML() to prevent
// utf-8 characters (e.g. accented letters) from being turned into entities
// At the same time, this will strip the DOCTYPE.
$div = $document
->getElementsByTagName("div")
->item(0);
return implode('', array_map([
$document,
'saveHTML',
], iterator_to_array($div->childNodes)));
}